Friday, September 9, 2022

Arduino Green/Red Blinker

Video

About

This Arduino setup has two LED's (one green on the left, one red on the right), a switch, and a button. The switch controls which LED is active (respective to left and right on the switch), and the button can be held down to make the active button blink.

I wanted to take what was done in class and build upon it. At first I wondered how I could get creative with just two inputs and two binary LED's, considering either LED basing their state on some discrete math operator of the two inputs (XOR, imply, etc.). I then recalled our previous exercise in blinking, and wondered if I could combine the two exercises.

Making blinking toggleable alongside switching the active LED would make the code need to be synchronous (unlike the delay() method in the Blink example) because the state of the switch would have to be read every update. Sure enough I was able to find a tutorial on writing such code, checking the time every update with mills() and keeping track of the last blink's timestamp.

Link to Code

Tutorials and Resources

How to Wire and Program a Button - Arduino Documentation

No comments:

Post a Comment

Sing-Pong (Arduino/Unity project)

  From the start, my goal was to create a voice-controlled game, of course within the limits of Arduino and its microphone component. Sing-P...