Output on Every Other Input (solved)

Hi All,

I'm almost done with my project. I mounted a switch to the machine which will signal my Arduino Uno to activate a 12 volt solenoid for 1 second. I've assembles all of the parts and wired it up on a breadboard. I've written the program and everything is working...... except for one thing. The switch will input twice for every desired output. I want the Arduino to output a signal to pin 2 the first time that the switch is pressed and released, and not the next time, and so on. I tried having a counter which advanced and then using the modulo when divided by 2 and comparing that to 0, but failed somehow. Other than taking another run at that is there some other idea to look at?

Thanks, Tom

The counter and modulo is what I would have suggested, so you'll need to elaborate on what "but failed somehow" actually means.....

EDIT: Presumably it's something like this? Did you remember to use == in the comparison not just a =?

Thanks, that is exactly what I did. I went back for a second try. I had used "debounce without delay" loops, and discovered that teh interval I chose was too short. It is working !!!!! Hurray.

Thanks All