I have been messing with relays and the Arduino this weekend so I decided to incorporate all that fun into a Party Button using the Amazon Dash. When you start a party a python script is started that sends a signal to the Arduino to fire up the relay. The Relay controls an outlet that has party lights and a stereo receiver atached to it. Everything is powered on and then the Python script will pick out a random song and start it up using VLC command line.
Python Script
I used python to setup the ARP sniffer (needed to sense when the Amazon Dash Button was pressed), pick out a random song from a directory, send a signal to start the relay using the Arduino, and play the selected song using VLC.
I had to send the off command (HIGH signal or 1) to the relay at the start of the script because when you activated the Serial port using Python it would automatically reset the signal to the Relay causing it to come on. So I set a sleep command to sleep 5 seconds and then send the off signal to turn off the relay.
Since the ARP sniffer required Linux to work properly (scapy library works out of the box in Linux) a nice side benefit was the fact I could send a signal directly to the serial port using the pySerial module.
Party Button Test Rounds
So we went through a few test rounds of the Party Button. I uploaded the video to YouTube. You can see I had 2 handy wingmen helping me with the testing.
0 comments:
Post a Comment