Counter

Hi all, I need to make a counter with outputs using Arduino. I will explain better:

What I need is that whenever a proximity sensor sends a pulse, the counter counts 1 and stays there until another proximity sensor tell Arduino to count another 1. And at of those counts I need an output to power a little DC motor and some leds. When the counts finish at the desire amount, the counter will reset it self and start again when the sensor tells it to. Any help will be so much appreciated.

Note: A reset and a pause button included would be nice!

Thank you very much.

einspace

Are you looking for sample code, someone to help you do it yourself, or someone to get it all done for you?

void loop() {
  for( loop through the sensors ) {
    if this sensor is on, and I havent had a pulse from this sensor yet {
      increment the pulse count, 
       note that I have had a pulse from this sensor.
    }
  }

  if(the pulse count is == the number of sensors I have) {
    set pulse count to zero
    clear out all the sensor notfications
    flash leds, spin motor
  }

}

Hi cedar

I would like to try it on my own, but I will need a sample code to start with. If I can't do it, then I can consider someone to make this for me. Do you have any sample code? Thanks.

Hi Paul

Should I use this code as is or I need to make some modifications? Thanks.

but I will need a sample code to start with.

Have you looked at the state change detection example? If not, why not? If so, what did it do that you don't want? What did it not do that you do want?

einspace: Should I use this code as is or I need to make some modifications? Thanks.

That's not code, it's pseudo-code. Idea of pseudo-code is to outline the algorithm, the process, the method call it what you will, the logic..... but it's not a program.

Hi Paul, what is a state change detection example? Sorry, I'm new on this.

einspace: Hi Paul, what is a state change detection example? Sorry, I'm new on this.

In the IDE, you can select examples from the File menu. One of them is called State Change Detection. There are tons of other useful examples, as well as some useless ones.

Ok Paul, will check it out. Thanks.

Ok guys, I think I know a better way to do this. I need Arduino to count 3 pulses from a proximity sensor and on the third pulse it sends a signal to a motor and when the motor rotates another proximity sensor that sense the position of the motor shaft will reset the counter. Thank you all.

Hi Paul, I tried the State Change Detection example and it does well to blink a led and to make it stay on the last state until state change again. But how I do to make Arduino to give an output when it has detected three pulses from a proximity sensor? Thanks.