如何制作一个arduino传送带带计数功能
效果图:
设计原理图:
线路示意图:
代码:
//Prateek
//www.prateeks.in
//https://youtu.be/LA65y0QgLNQ
#include "LiquidCrystal.h"
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int irPin = 6;
int count1 = 0;
int irPin2 = 5;
int count2 = 0;
boolean state = true;
boolean state1 = true;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(irPin, INPUT);
lcd.setCursor(0, 0);
lcd.print(" Hi Welcome To");
lcd.setCursor(0,1);
lcd.print("JustDoElectronics");
delay(2000);
lcd.setCursor(0, 0);
lcd.print("Counter Machine");
lcd.setCursor(0, 1);
lcd.print("...............");
delay(2000);
lcd.clear();
}
void loop()
{
if (!digitalRead(irPin) && state) {
count1++;
state = false;
lcd.setCursor(0, 0);
Serial.print("Large Bottle: ");
lcd.print("Total Bottle:");
Serial.println(count1);
lcd.setCursor(14, 0);
lcd.print(count1);
delay(100);
}
if (digitalRead(irPin))
{
state = true;
delay(100);
}
if (!digitalRead(irPin2) && state) {
count2++;
state1 = false;
lcd.setCursor(0, 1);
Serial.print("Large Bottle: ");
lcd.print("Small Bottle:");
Serial.println(count2);
lcd.setCursor(14, 1);
lcd.print(count2);
delay(100);
}
if (digitalRead(irPin2))
{
state1 = true;
delay(100);
}
}
效果图:
原项目地址:
https://www.prateeks.in/2022/07/how-to-make-conveyor-belt-system.html#google_vignette
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。