** Found the solution, first the original topic then the solution is under it **
Hello everyone,
What I want to do is this, each time my IR sensor picks up movement and gives out 0 instead of 1,
I want a variable on the LCD screen to be added 1 to it.
For example:
"Pessoas: 0" Someone walks in front of it >>>> "Pessoas: 1"
Right now I am able to display the variable to the lcd, but I really don't know with my noobish code
skills how to do what I need.
Here is what I tried so far and obviously does not work the way I want it to:
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,9,10,11,12);
void setup() {
Serial.begin(9600);
pinMode(2,INPUT);
lcd.begin(16, 2);
lcd.clear();
lcd.print("Passantes:");
}
void loop() {
int irread = digitalRead(2);
Serial.println(irread);
delay(540);
lcd.setCursor(0, 1);
lcd.print("Pessoas ");
int Pessoas = 0;
if (irread = 0);
Pessoas = Pessoas + 1;
lcd.print(Pessoas);
}
EDIT.: Ok I was able to make it work by doing:
int Pessoas = 0;
void loop() {
int irread = digitalRead(2);
Serial.println(irread);
delay(500);
lcd.setCursor(0, 1);
lcd.print("Pessoas ");
if (irread == 0){
Pessoas = Pessoas +1;
lcd.print(Pessoas);
}
}
My main mistake was putting the int inside the loop I guess. Now it works as it should.
Thanks everyone you can now close the topic. Hope this helps somebody.