The goal of this project was to build on the basic button-press example code in arduino and create a switch that actually turned the light off when the button was released. In the code, we had to factor in debouncing, or the mechanical error that occurs when sensors misread a single press as multiple presses. In order to counteract this we set the debounce time to 200 milliseconds and created an if then statement that factored in the duration of the debounce. See the entire code at my Github. And you can find my source code here.
- Arduino Uno
- 220 resistor
- 10K resistor
- 5 wires
- LED Pin
- Button Pin
With my first go at the code, I couldn't get the LED to light up. I saw that the embedded LED was responding the way I wanted it to, so I knew my code was OK. I started double checking my connections and placement or everything on the board and realized I had my LED bulb backward. Whoops! Anyway, the last video is when I finally got it to work.
I could see myself using this code again as a non-verbal cue for an immersive experience. Imagine an immersive game where you are in a pitch black room. You're instructed to only ask yes or no questions in order to exit the room. You ask questions into the darkness and when the answer is yes, you see a glowing green light. When the answer is no, you see a glowing red light. Both triggered by the silent push of a button.