Engineer's Asylum

Please any one can check these codes

#1
#include <LiquidCrystal.h> // includes the LiquidCrystal Library 
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7) #include <LiquidCrystal.h> // includes the LiquidCrystal Library LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7) 
#include <Wire.h> 
int ir = A0;
int ir1 = A2;
int counter=0 ;
int currentState = 0;
int previousState = 0;

int counter1=0 ;
int currentState1 = 0;
int previousState1 = 0;
int total;

void setup() {
lcd.begin(16, 2);

pinMode(ir,INPUT);
pinMode(ir1,INPUT);

lcd.setCursor(0,0);
lcd.print("In = ");

lcd.setCursor(8,0);
lcd.print("OUT = ");

lcd.setCursor(0,1);
lcd.print("total = ");

}

void loop(){

int total= (counter -counter1);

if (digitalRead(ir)==0 ){

currentState = 1;
}
else {
currentState = 0;
}

if(currentState != previousState){
if(currentState == 1){

counter = ++counter ;
total= ++total;

lcd.setCursor(4,0);
lcd.print(counter);

lcd.setCursor(8,1);
lcd.print(total);
delay(500);

}
}
if (digitalRead(ir1)==0 ){

currentState1 = 1;
}
else {
currentState1 = 0;
}

if(currentState1 != previousState1){
if(currentState1 == 1){

counter1 = ++counter1;
total= --total;
lcd.setCursor(13,0);
lcd.print(counter1);

lcd.setCursor(8,1);
lcd.print(total);

delay(1000);

}
}
}
0 Likes

#2

Hello! Welcome to our community!!

You have to add more details while creating a new post. What are the issues with the above code?
Do you have any error in this code? What’s the purpose of the code? Simply posting code and asking to check is not going to help anyone. Please update it with more details!

0 Likes