Creating a Raspberry Pi Controlled Rockstar Energy Drink Sign

Project Text:
I wanted to create a way to turn my really cool Rockstar energy drink LED sign on and off remotely and automatically at certain times. So, I threw together a relay, a raspberry pi, an AC cord and outlet, some wires, a tiny bit of code, and a 3D-printed outlet holder tray, and created a cool result! You can turn the light on via `/home/pi/gpio_code/on` and off via `/home/pi/gpio_code/off` and set a schedule for the light to turn on and off using `crontab -e`.

Required Links:
Raspberry Pi GPIO pin control (wiringpi) download and install: http://wiringpi.com/download-and-install/
Raspberry Pi GPIO pin layout: http://pi4j.com/images/p1header.png
3D printed Wall outlet holder tray: https://www.thingiverse.com/thing:15153

Required Code:
cd ~
mkdir gpio_code
cd ~/gpio_code
sudo nano on.cpp

sudo nano off.cpp

Required Configuration:
sudo raspi-config #set timezone under `Localization Options` -> `Change Timezone`
sudo crontab -e # append the following four lines:
# 8 am on
0 8 * * * /home/pi/gpio_code/on
# 8 pm off
0 20 * * * /home/pi/gpio_code/off

Connect the raspberry pi to a relay as follows:

Note
If you want to create a shortcut on your desktop to turn the light on or off, you can use plink.exe, which comes with PuTTY, by creating shortcuts with the following properties (replacing the credentials and IP address with your own):

For Light Off:
“C:\Program Files\PuTTY\plink.exe” -ssh -2 -l pi -pw raspberry 172.16.2.103 /home/pi/gpio_code/off

For Light On:
“C:\Program Files\PuTTY\plink.exe” -ssh -2 -l pi -pw raspberry 172.16.2.103 /home/pi/gpio_code/on

That’s it!

Other Additions

I wanted to add a button so I could toggle the state of the Rockstar Energy Drink sign, so I connected GPIO 2 to a button and the other terminal of the button to 5V. Then I wrote a background program to check the state of the switch, and toggle the Rockstar Energy Drink sign state (being on or off) when the button is pressed.

Diagram:

Here is the code for that:
sudo nano buttonmonitor.cpp

To make the executable buttonmonitor run at startup, we have a few options, but for this project we are going to edit /etc/rc.local. Right before the last line of `exit 0` we are going to write `/home/pi/gpio_code/buttonmonitor &` which will make the buttonmonitor executable run in the background on startup.

Thanks for reading!