Santa brought this launch button from Amazon: Launch Button. Taking it apart to review the wiring I quickly realized I had an issue. The green button has an LED in it, but also has a fuse. This light will not come on unless you provide 220V of power...uh...there is no way I am lighting this cheap chinese plastic box up with 220 volts of power to light up a silly LED.
So I stripped down the button and the guts, removing the fuse, feeding some wires through the switch and up to a cheap LED I had laying around. I wired this to the Raspberry Pi GPIO. Then I hooked up the key to another GPIO pin. So I read the pin on the key and if it has power than i turn on the LED.
I snagged a 3V relay for some other ESP8266 project I was working on and headed over to Home Depot to grab an outlet. I used some 3M tape to adhere the relay to an outlet box and juiced up both outlets to the relay. I'd like to control both outlets separately but I hosed up when I ordered the relay and only ordered a 1 Channel Relay.
With most of the hardware components wired up I started on the software side. After several rounds of testing I came up with the python script that would read to see if the Key was in the on position, if so then light up the LED. If you press the Green button it will then fire up the relay and then pick a random song from the folder. If the key is not in the on position then pushing the green button will do nothing and the LED will not light up.
Key and Green Button Code
So finally I needed a way to quickly kill all this. I decided the Red Mushroom button would be the party kill switch. I turn off the LED, turn off the relay and also kill the VLC and Launch Button python script. This will shut the party down hard. I made this a separate script that will listen on a 3rd GPIO port to see when I push the kill switch button.
Pretty happy with how it turned out. Took about 4 days of tinkering to get it right. Here is a Youtube Video of the button in action:
0 comments:
Post a Comment