Buttons and Blinkenlights

Part 4 of the Digital I/O assignment. The circuit is as described in the assignment: two buttons, three LEDs. LEDs are controlled independently by two digital switches controlled by the buttons.

The software is somewhat more clever than expected. To avoid delays() which hinder button responsiveness, I use millis() to track current time and do not throttle the run loop. Also, by keeping track of the previous button state, a single button push yields a single increment to the counter.

The right button and left buttons respectively increment and decrement a counter variable, which reflects the rate at which LEDs blink. The counter variable spans the range [0,7], and it’s current value is reflected in binary on the LED display.

Arduino Sketch: smus_blink_counter

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: