I have an Arduino Uno and a 555 timer configured to astable mode.
What I'm trying to do is to program my Arduino to increase a "counter" variable (counter++) everytime it gets triggered by 555 timer's output (through analogIN pin).
My problem is that Arduino takes 555 timer's output as a continuous triggering and increases my counter as long as the pulse in the analogIN lasts. So instead of incrementing by 1, it is increased by approximately 97 (sometimes more or less).
I need to take the analog in as a "packet" so everytime analogIN is triggered, no matter how long the pulse lasts, it will be treated as a single event and not as continuous triggering.
What do I have to change?
My code:
int counter = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if(analogRead(A0) > 250) {
counter++;
Serial.println(counter);
}
}
Thanks
high
, but you assume thatlow
will somehow be magically checked also – jsotola May 13 at 16:28