Toggle Switching ~ Display clock


My newest challenge to myself is to make a clock to display the time/date/month/year/sec etc.... the question that i'm wanting to know, i currently have one of these toggle switches,15642.0.html,

Is it possible to connect these to the arduino to perform increments and decrements to the clock, for example, if(pin2 is high) months++; // although this is bad example, using it to demonstrate how i want the toggles to act if(pin3 is high) months--;

Ive coded this type of thing before on a ATMEGA32, using AVR, would it be a better idea for me to get avr studio and code it that way? with a JTAG MKII? in summary : a clock that displays day/time/month, with toggles to increment and decrement the values to set the time. (4 toggles switches, both way)

It’s possible if it is the type of switch that returns to the middle. If it is a normal on/off toggle, it won’t work right.

Momentary (IE A push button) would make your life a lot easier, but you could make this work. Just keep in mind that with your code example, every time your code loops it will increment month as long as the switch is in place. You'll want to either add in some for of polling delay (Only check every N milliseconds), or look just for transitions. Don't forget to debounce your switch.

@hazards/@mirith, yes it is a three way switch that sits in the middle, and can be moved forward and backwards, thanks for the help guys, when i receive my screen off ebay ill have a crack and post some progress!, for the increments i make it wrap around (if months<0 months=months+11), and if its greater then 12 it wraps back to zero.