How to drive Arduino UNO as a counter triggered by 555 timer's output (astable mode) 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) &gt; 250) {
    counter++;
    Serial.println(counter);
  }

}


Thanks
You need to create a finite state machine with 2 states:


Waiting for input from 555 to go high.  When this happens increment the counter &amp; advance to the next state.
Waiting for the input from the 555 to go low.  When this happens advance to the next state.  That is, the first state.


In the following Arduino "State Change Detection (Edge Detection) for pushbuttons" example / tutorial you do not need the complex code to debounce the switch.  However, the edge detection and state machine portion of the code can likely be applied to your project.