Arduino objects product counting system designing and programming
Description:
Product counting –In this tutorial, you’ll learn how to use Arduino, 16×2 LCD and an IR infrared sensor to create your own Industrial level product counting system. It will also work with Arduino Mega on this venture.
Object counters and product counters are most widely used in industries around the world, the project we are going to be working on today can be used to count various types of items and goods. I’ll also clarify how you can count objects/products that actually touch each other in this tutorial. Through creating SolidWorks 3d, I’ll explain the whole premise.
The Amazon Purchase links are given below:
Arduino Uno: https://amzn.to/39aq6ZT
Mega 2560: https://amzn.to/2SszMsI
16×2 lcd: https://amzn.to/2Q9pblc
lm7805 Voltage Regulator: https://amzn.to/2ERYoTJ
330-ohm resistors pack: https://amzn.to/2Qj1Igg
female DC power jack socket: https://amzn.to/377Pg9M
470uf capacitors: https://amzn.to/2MrN3xR
5×7 cm Vero board: https://amzn.to/37b7KWO
female headers: https://amzn.to/350w6RE
connection wires: https://amzn.to/2MvOJXd
Super Starter kit for Beginners: https://amzn.to/398dliF
Jumper Wires: https://amzn.to/2SrnBwo
Bread Board: https://amzn.to/2MxV5FM
12v Adaptor: https://amzn.to/2MuOlZk
PCB plate: https://amzn.to/2MuwNMB
Variable Supply: https://amzn.to/39d0KdP
Digital Multimeter: https://amzn.to/34WbVoa
Vero Board / stripboard: https://amzn.to/39nL9Zg
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2PVwexF
Solder wire: https://amzn.to/2QlOvTS
Wire Stripper: https://amzn.to/353tYJa
wirecutter: https://amzn.to/2tV2lFj
PCB small portable drill machine: https://amzn.to/2MvQqnx
DISCLAIMER:
Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
Product counting Circuit Diagram:
This is the ball counting process simulation. As you can see
- Pin number 1 of 16×2 LCD is attached to the ground.
- The number 2 pin is linked to the 5volts.
- Pin number 3 which is the LCD’s contrast pin should be connected to a variable resistor, and the variable resistor can then be used to control the contrast of the lcd. Because this is only a simulation, a variable resistor does not need to be attached.
- The LCD’s rs pin is connected to Arduino’s pin number 9.
- The LCD pin number 5 is attached to the ground.
- The LCD’s enable pin is connected to Arduino’s pin number 8.
- The Arduino pins 4, 5,6 and 7 are connected to the LCD data pins D4 to D7.
16×2 LCD essentially has 16 pins, but pin number 15 and pin number 16 are not shown as you can see. You need to connect pin number 15 with 5 volts and pin number 16 to the ground during the actual hardware connections.
The two push buttons attached to pin number 2 and pin number 3 are the infrared sensors. This push button will be used to count the balls when resetting this relay with this push button.
In this project a 12v relay will be used; if you want, you can also use a 5v relay. The 12v relay form I use is SPDT. Each form of relay has 5 pins, 2 coil pins, common pin, normally open and normally close pin.The transistor leg of 2n2222 NPN is attached to the ground while the collector is linked to the relay coil. While the relay coil’s other side is connected to the 12v as it’s a 12-volt relay …
The base of the 2n2222 transistor is connected to a 10k resistor. This transistor is checked using Arduino’s pin number 13. The aim of this relay is to activate the other circuits, when the box is full, it can be used to turn on a buzzer, or it can be used to cause the pneumatic cylinder to move the box.
Download: simulation
Download: solidworks files
Product counting Programming:
This is the consumer counting system’s full software. The 16×2 LCD is used, as in this task, to show the number of counted products/objects. And we’ll have to use the Liquid Crystal library to use this LCD. So I began by adding the header file for LiquidCrystal.h.# This is a preprocessor directive, whereas.h is a header file. I marked the LCD’s next buttons.
1 2 3 4 5 6 7 8 9 10 11 12 |
#include <LiquidCrystal.h> #define rs 9 #define en 8 #define d4 7 #define d5 6 #define d6 5 #define d7 4 LiquidCrystal lcd(rs, en, d4, d5, d6, d7); int relay = 13; |
Use this relay to signal another device or turn a light or a buzzer on. This will signal that the box is complete to the operator or other machine. You can then remove the box manually or drive it through the pneumatic cylinder and so on.
Then I specified two form unsigned integer variable ballcount and tballs and initially set them to zero. I finally defined two ballf and resetb variables. Such variables belong to the integer type.
1 2 3 4 |
unsigned int ballcount = 0; unsigned int tballs = 0; // total balls int ballf = 0; // ball flag. int resetb = 3; // to reset the relay , this can be laser or an infrared sensor. |
First I activated the lcd in the void setup function and entered the number of columns and rows. Since this is a 16×2 lcd. 16 columns and 2 rows. Then I used the lcd to print a “Tballs Current” message. Since this is a LCD of 16×2. Sixteen columns and two rows. Then I used the lcd to print a message “Tballs Current.”Action printing. To print strings on the lcd, the lcd.print function is used. Instead, I turned on the Arduino’s pin number 2 interrupt. The Arduino pin number 2 will be used for counting items or objects. And finally using the function pinMode I told the controller which pins are being inputted and which pins are being outputted.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("TBalls Current"); attachInterrupt(0, add, FALLING); pinMode(resetb, INPUT); digitalWrite(resetb, HIGH); pinMode( relay, OUTPUT); digitalWrite(relay, LOW); ballcount = 0; tballs = 0; } void loop() { if ( ballf == 1 ) // the lcd is updated only when ballf = 1, this way the controller won't be busy in printing the values on lcd again and again. { //Print out result to lcd lcd.clear(); lcd.print("TBalls Current"); lcd.setCursor(0,1); lcd.print(tballs); lcd.setCursor(8,1); lcd.print(ballcount); ballf = 0; } if ( digitalRead(resetb) == LOW) { digitalWrite(relay, LOW); } } void add() { ballf = 1; ballcount++; tballs = tballs + 1; if (ballcount >= 5) { digitalWrite(relay, HIGH); ballcount = 0; } } |