Arduino Model of a Belt Conveyor
Model of a Belt Conveyor With Product Counter & Weight Measurement
Components and supplies
1
12V 3A Power Supply
4
DC Motor, 12 V
1
Jumper wires (generic)
1
SparkFun Load Cell Amplifier - HX711
1
Arduino Nano R3
1
LCD Module 16x2
1
Load Cell (1.5Kg)
3
Pushbutton Switch, Momentary
2
L298N Motor Driver
1
IR Sensor
Apps and platforms
1
Arduino IDE
Project description
Code
Belt Conveyer Code
arduino
1//2020 Craftybin.blogspot.com 2//Author : Chathura H. 3 4#include 5 "HX711.h" 6const int LOADCELL_DOUT_PIN = 2; 7const int LOADCELL_SCK_PIN = 8 3; 9HX711 scale; 10 11#include <Wire.h> 12#include <LiquidCrystal_I2C.h> 13LiquidCrystal_I2C 14 lcd(0x27, 16, 2); 15 16#define plus A2 17#define minus A1 18#define enter A0 19 20const 21 int motorPin1 = 5; 22const int motorPin2 = 6; 23const int motorPin3 = 7; 24const 25 int motorPin4 = 8; 26const int motorPin5 = 9; 27const int motorPin6 = 10; 28const 29 int motorPin7 = 11; 30const int motorPin8 = 12; 31 32int IR = 13; 33int count1 34 = 0; 35int count2 = 0; 36int detect1 = HIGH; 37int detect2 = LOW; 38int detect3 39 = LOW; 40int detect4 = LOW; 41 42void setup() 43{ 44 lcd.begin(); 45 pinMode(motorPin1, 46 OUTPUT); 47 pinMode(motorPin2, OUTPUT); 48 pinMode(motorPin3, OUTPUT); 49 pinMode(motorPin4, 50 OUTPUT); 51 pinMode(motorPin5, OUTPUT); 52 pinMode(motorPin6, OUTPUT); 53 pinMode(motorPin7, 54 OUTPUT); 55 pinMode(motorPin8, OUTPUT); 56 pinMode(IR,INPUT); 57 pinMode(plus,INPUT); 58 59 pinMode(minus,INPUT); 60 pinMode(enter,INPUT); 61 Serial.begin(9600); 62 63 delay(100); 64 65 Serial.println("Product Weight "); 66 Serial.println("Measuring..."); 67 68 scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); 69 scale.set_scale(2280.f); 70 71 scale.tare(); 72 lcd.backlight(); 73 lcd.print("Product Weight"); 74 delay(1000); 75 76 lcd.clear(); 77 78} 79 80 81void loop() 82{ 83 detect1 = digitalRead(IR); 84 85 detect2 = digitalRead(plus); 86 detect3 = digitalRead(minus); 87 detect4 88 = digitalRead(enter); 89 90 Serial.print("one reading:\ "); 91 Serial.print(scale.get_units(), 92 1); 93 Serial.print("\ | average:\ "); 94 Serial.println(scale.get_units(10), 95 1); 96 97 scale.power_down(); 98 delay(100); 99 scale.power_up(); 100 101 102 if (detect1 == LOW) { 103 if(count1 < 10) 104 count1++; 105 else 106 107 count1 = 0; 108 lcd.backlight(); 109 lcd.print("COUNTER ="); 110 delay(500); 111 112 lcd.clear(); 113 lcd.print(count1); 114 delay(500); 115 lcd.clear(); 116 } 117 118 119 120 if (detect2 == HIGH) { 121 if(count2 < 10) 122 count2++; 123 124 else 125 count2 = 0; 126 lcd.backlight(); 127 lcd.print("Set Count"); 128 129 delay(500); 130 lcd.clear(); 131 lcd.print(count2); 132 delay(500); 133 lcd.clear(); 134 135 } 136 137 138 if (detect3 == HIGH) { 139 if(count2 < 10) 140 count2--; 141 142 else 143 count2 = 0; 144 lcd.backlight(); 145 lcd.print("Set Count"); 146 147 delay(500); 148 lcd.clear(); 149 lcd.print(count2); 150 delay(500); 151 lcd.clear(); 152 153 } 154 155 156 if (detect4 == HIGH){ 157 158 if (count2 > count1){ 159 digitalWrite(motorPin1,HIGH); 160 161 digitalWrite(motorPin2,HIGH); 162 digitalWrite(motorPin3,HIGH); 163 digitalWrite(motorPin4,HIGH); 164 165 lcd.backlight(); 166 lcd.print(" Counting ="); 167 delay(500); 168 lcd.clear(); 169 170 lcd.print(count1); 171 delay(500); 172 lcd.clear(); 173 } 174 175 176 else if (count2 <= count1){ 177 digitalWrite(motorPin1,LOW); 178 digitalWrite(motorPin2,LOW); 179 180 digitalWrite(motorPin3,LOW); 181 digitalWrite(motorPin4,LOW); 182 lcd.backlight(); 183 184 lcd.print("Count Completed"); 185 delay(500); 186 lcd.clear(); 187 lcd.print(count1); 188 189 delay(500); 190 lcd.clear(); 191 } 192 } 193 194 else { 195 digitalWrite(motorPin1,LOW); 196 197 digitalWrite(motorPin2,LOW); 198 digitalWrite(motorPin3,LOW); 199 digitalWrite(motorPin4,LOW); 200 201 } 202 203if (scale.get_units() > 1200 || scale.get_units() < 800) 204 205 { 206 digitalWrite(motorPin4,LOW); 207 digitalWrite(motorPin5,LOW); 208 209 210 digitalWrite(motorPin6,HIGH); 211 digitalWrite(motorPin7,LOW); 212 213 delay(1000); 214 digitalWrite(motorPin6,LOW); 215 digitalWrite(motorPin7,HIGH); 216 217 delay(1000); 218 lcd.backlight(); 219 lcd.print(" Weight Unmatched"); 220 221 delay(500); 222 lcd.clear(); 223 lcd.print("Rejecting"); 224 delay(500); 225 226 lcd.clear(); 227} 228 229else { 230 digitalWrite(motorPin6,HIGH); 231 digitalWrite(motorPin7,LOW); 232 233 digitalWrite(motorPin6,LOW); 234 digitalWrite(motorPin7,LOW); 235} 236} 237 238 239 240 241
Belt Conveyer Code
arduino
1//2020 Craftybin.blogspot.com 2//Author : Chathura H. 3 4#include "HX711.h" 5const int LOADCELL_DOUT_PIN = 2; 6const int LOADCELL_SCK_PIN = 3; 7HX711 scale; 8 9#include <Wire.h> 10#include <LiquidCrystal_I2C.h> 11LiquidCrystal_I2C lcd(0x27, 16, 2); 12 13#define plus A2 14#define minus A1 15#define enter A0 16 17const int motorPin1 = 5; 18const int motorPin2 = 6; 19const int motorPin3 = 7; 20const int motorPin4 = 8; 21const int motorPin5 = 9; 22const int motorPin6 = 10; 23const int motorPin7 = 11; 24const int motorPin8 = 12; 25 26int IR = 13; 27int count1 = 0; 28int count2 = 0; 29int detect1 = HIGH; 30int detect2 = LOW; 31int detect3 = LOW; 32int detect4 = LOW; 33 34void setup() 35{ 36 lcd.begin(); 37 pinMode(motorPin1, OUTPUT); 38 pinMode(motorPin2, OUTPUT); 39 pinMode(motorPin3, OUTPUT); 40 pinMode(motorPin4, OUTPUT); 41 pinMode(motorPin5, OUTPUT); 42 pinMode(motorPin6, OUTPUT); 43 pinMode(motorPin7, OUTPUT); 44 pinMode(motorPin8, OUTPUT); 45 pinMode(IR,INPUT); 46 pinMode(plus,INPUT); 47 pinMode(minus,INPUT); 48 pinMode(enter,INPUT); 49 Serial.begin(9600); 50 delay(100); 51 52 Serial.println("Product Weight "); 53 Serial.println("Measuring..."); 54 scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); 55 scale.set_scale(2280.f); 56 scale.tare(); 57 lcd.backlight(); 58 lcd.print("Product Weight"); 59 delay(1000); 60 lcd.clear(); 61 62} 63 64 65void loop() 66{ 67 detect1 = digitalRead(IR); 68 detect2 = digitalRead(plus); 69 detect3 = digitalRead(minus); 70 detect4 = digitalRead(enter); 71 72 Serial.print("one reading:\ "); 73 Serial.print(scale.get_units(), 1); 74 Serial.print("\ | average:\ "); 75 Serial.println(scale.get_units(10), 1); 76 77 scale.power_down(); 78 delay(100); 79 scale.power_up(); 80 81 if (detect1 == LOW) { 82 if(count1 < 10) 83 count1++; 84 else 85 count1 = 0; 86 lcd.backlight(); 87 lcd.print("COUNTER ="); 88 delay(500); 89 lcd.clear(); 90 lcd.print(count1); 91 delay(500); 92 lcd.clear(); 93 } 94 95 96 if (detect2 == HIGH) { 97 if(count2 < 10) 98 count2++; 99 else 100 count2 = 0; 101 lcd.backlight(); 102 lcd.print("Set Count"); 103 delay(500); 104 lcd.clear(); 105 lcd.print(count2); 106 delay(500); 107 lcd.clear(); 108 } 109 110 111 if (detect3 == HIGH) { 112 if(count2 < 10) 113 count2--; 114 else 115 count2 = 0; 116 lcd.backlight(); 117 lcd.print("Set Count"); 118 delay(500); 119 lcd.clear(); 120 lcd.print(count2); 121 delay(500); 122 lcd.clear(); 123 } 124 125 126 if (detect4 == HIGH){ 127 128 if (count2 > count1){ 129 digitalWrite(motorPin1,HIGH); 130 digitalWrite(motorPin2,HIGH); 131 digitalWrite(motorPin3,HIGH); 132 digitalWrite(motorPin4,HIGH); 133 lcd.backlight(); 134 lcd.print(" Counting ="); 135 delay(500); 136 lcd.clear(); 137 lcd.print(count1); 138 delay(500); 139 lcd.clear(); 140 } 141 142 else if (count2 <= count1){ 143 digitalWrite(motorPin1,LOW); 144 digitalWrite(motorPin2,LOW); 145 digitalWrite(motorPin3,LOW); 146 digitalWrite(motorPin4,LOW); 147 lcd.backlight(); 148 lcd.print("Count Completed"); 149 delay(500); 150 lcd.clear(); 151 lcd.print(count1); 152 delay(500); 153 lcd.clear(); 154 } 155 } 156 157 else { 158 digitalWrite(motorPin1,LOW); 159 digitalWrite(motorPin2,LOW); 160 digitalWrite(motorPin3,LOW); 161 digitalWrite(motorPin4,LOW); 162 } 163 164if (scale.get_units() > 1200 || scale.get_units() < 800) 165 { 166 digitalWrite(motorPin4,LOW); 167 digitalWrite(motorPin5,LOW); 168 169 digitalWrite(motorPin6,HIGH); 170 digitalWrite(motorPin7,LOW); 171 delay(1000); 172 digitalWrite(motorPin6,LOW); 173 digitalWrite(motorPin7,HIGH); 174 delay(1000); 175 lcd.backlight(); 176 lcd.print(" Weight Unmatched"); 177 delay(500); 178 lcd.clear(); 179 lcd.print("Rejecting"); 180 delay(500); 181 lcd.clear(); 182} 183 184else { 185 digitalWrite(motorPin6,HIGH); 186 digitalWrite(motorPin7,LOW); 187 digitalWrite(motorPin6,LOW); 188 digitalWrite(motorPin7,LOW); 189} 190} 191 192 193 194
Downloadable files
Belt Conveyer Design
Connection Diagram
Belt Conveyer Design

Comments
Only logged in users can leave comments