Hi Guys
I just need a little guidance if I may. Im new in the whole electronics scene.
As a beginner project, I'm trying to make a visual pedometer using LEDs as indicator for the number of steps (by 10's or100's steps per LED) and using a tilt switch as a counter.
Im trying this out first with 3 LEDs and a button switch just to try it out. Ive wired anddsketched the below and basically it doesnt work. Can you help me please? Ultimately I want to make an Iron Man Arc reactor pedometer where if you reach your goal total of steps the whole thing will light up.
thanks guys & gals
buton_pedometer_trial.ino (905 Bytes)
The variable buttonpresses is incremented by each of the following if statements until the value exceeds the conditionals. While you are checking the button pin there is no debouncing so if you hold your finger down more than 100mS it will increment again and so forth. You need to add some debounce delay.
http://playground.arduino.cc/Code/Bounce
I assumed that you have pin-2 connected to one side of a switch with a 10k pulldown resistor on the same pin and a 1 k pullup on the other terminal of the switch since your code defines the button ACTIVE state as HIGH, that means the INACTIVE state must be low and pulled down with the 10k resistor to GND.
buton_pedometer_trial_MODIFIED.ino (1.35 KB)