I created a switch using digital input to let someone know whether they’ve successfully closed a door or not. It’s extremely clunky, ugly, and needs to be reset every time you open the door again — which I think makes it very funny. To start, here’s a picture of the finished product:
I had a ton of technical issues trying to get this done last night. It took me about an hour and a half just to get the Arduino code working — first I was stuck in the board installation, then when I tried to cancel and start over I got some error messages, then I decided to update my OS to see if that was causing issues, then when I had everything installed I couldn’t find the USB port attachment for my laptop, then when everything was finally set, I tried to run the code some five times without realizing I had the wrong Arduino board selected. A few rage tears were shed in the process, but the relief I felt when I got that first LED light working was immense.
From then, I followed Scott’s switch as toggle code but adding another LED to provide both “good” and “bad” feedback. Here’s my code:
LEDPinG and ledGState refer to the Green light, which signifies the door is closed (good). LEDPinR and ledRState refer to the Red light, which signifies the door is open (bad). Toggling the switch alternates between the two lights — if one is off, the other is on.
At that point, I already had the board taped up to my wall, but hadn’t figured out how to make the door trigger the tiny button. Here’s me testing that the code worked (you can see I accidentally pressed it twice. It’s such a tiny button.)
Without fancier switches available, I ended up using a skewer taped to my door to trigger the button. This is the first test of that — you’ll notice I moved the switch, taping it onto the actual doorframe. I broke the skewer in half, but it was still too long — it just lightly touched the button, I think because the leverage point was too far away from the button.
In the last test, I cut the skewer in half once again to bring it closer to the board. I also added some text to give additional feedback to the user. I think the way the tape peels back has some absurdist, amazing comedic effect to it. It gives the skewer/tape combo a hint of anthropomorphism, something reminiscent of a runner’s legs giving out after crossing the finish line in a marathon. It’s very silly, and I love it.