hi, im new here and with the arduino ..i have little arduino programing knowledge . so i made a sort of reflective sensor using a phototransistor and ir led and i want it to count an encoder strip with black and white lines .i hav made a code:
int count = 0 ;
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(count, DEC);
if (sensorValue < 1000)
{
count = count + 1;
delay (1000);
}
else
{
count = count + 0;
}
}
this counts the number of white lines it sees but there is one problem i want it to increase count one time when it sees a white line but now if i keep a white line on the sensor it keeps on counting? who can i limit one count per white line??