Lights and Switches

Who doesn't like pushing buttons and seeing lights appear?
This was mainly inspired by various real and fictional cockpits of various vehicles, at least, in theory. In Star Wars, Han Solo flips a bunch of switches and pushes several buttons, with corresponding lights appearing on the console, before jumping to lightspeed. There's an inherent satisfaction in watching that interaction, and even more of one in performing it. It's certainly helped by having more satisfying switches and lights than the ones which came in my Arduino kit, but that's a limitation I'm willing to accept for demonstration purposes.

The central conceit of this dumb little machine is that it "powers on" with the pot, signified by a red LED, and then can begin the "launch sequence", which consists of pressing both of the two buttons next to the pot. Each button lights more green LEDs, and when everything is lit, the blue LED lights up, signifying completion of the sequence. The blue LED will turn off when either of the buttons are pressed again, or when the "power" is shut off entirely. When the "power" is turned back on, everything is reset to off.

The wiring is probably as expected - individual power/ i/o to each switch/LED with the appropriate resistors. An issue I encountered was that the switches would not stay "registered" every time I pressed them- they would turn off when I let go of the button, instead of when I pressed them again. I had put booleans into the code to deal with this issue, but my theory is that with the way the switch checks are written into the code, it checks the switch while it's pressed multiple times, essentially putting the actual result to chance, depending on the "step" which the user lets go of the button.

There's probably an easy, obvious solution to this that I missed. Code is here.
https://pastebin.com/8h3hLRqZ

Comments

Popular posts from this blog

veins - a weird visual toy

Squeezy Circle

Audio-Reactive Drawing Machine