Introduction: Start Your Christmas Light Show With a Button
When running a Christmas light show synced to music you might want to start the show by pressing a button. This tutorial is only applicable for a show that is controlled through Falcon Pi Player (FPP) running on a Raspberry Pi. If you're running FPP then you're probably using Falcon controllers and using xLights or LightORama to sequence your show. If none of those words mean anything to you, this tutorial is probably a little bit over your head for now and you should start by reading this wiki https://auschristmaslighting.com/wiki/ and joining a Facebook group like below
- xLights: https://www.facebook.com/groups/xLights
- General advanced christmas lights: https://www.facebook.com/groups/pixelsandrgb/
- Falcon Pi Player: https://www.facebook.com/groups/FalconPlayer
- Enclosure/prop idea sharing: https://www.facebook.com/groups/186301722156865/
- "Not specifically xLights or LOR Related": https://www.facebook.com/groups/Not.xLights.or.LOR.But
- xLights Holiday Light vendors: https://www.facebook.com/groups/1607113736253241/
- Do It Yourself Christmas: https://www.facebook.com/groups/diychristmas
Step 1: Parts List
You'll need the following items:
- A button. I used this one with an LED ring light around it: [Amazon]
- A resistor. Preferably 200Ω or greater (2 of these if you're using the LED button) Standard 1/4W or 1/8W is fine
- Connector wire. The gauge you should use depends on how far the button will be from your Pi. I used 18awg wire for about 10 feet from my Pi and it worked flawlessly
- A way to connect a wire to the Pi's GPIO pins. You can use a ribbon cable with the breakout breadboard, or you can just use some female connectors like I did. We only need 3 wires - Ground, 5V, and data for button. [Amazon]
- (Optional) A waterproof connector on each end for easy maintenance. I use 3-pin marine grade connectors: [Amazon]
- (Optional) Heat shrink butt connectors [Amazon]
Step 2: Wiring Diagram
The pictures show a wiring diagram for a button without an included LED, and a button with an LED. The way I set up the wiring diagram allows you to run a button and a light (continuously on) with just 3 wires.
For the GPIO pin, pick any of the GPIO pins on the pi. Use the +5V and Gnd pins as well. You could probably get away with using the 3.3V pin, but the voltage drop across several feet of wire might make the signal unreliable or not be enough to light up the LED.
NOTE: The 3-pin connector will not fit through the hole you need to drill for a button with the LED ring light. So attach the connector after putting the button in your faceplate.
Step 3: Falcon Pi Player Basic Setup
NOTE - FPP is constantly being updated, and it's totally possible that they'll improve their scripting support or that they'll include "push button to start" as a default feature that requires less programming.
I followed the above video for initially getting everything set up.
I find videos boring and slow, so here's a summary of it:
- Import your sequence to fpp using the file manager
- Create a playlist with the sequence in it. For the next steps the playlist will be called "playme"
- Open a blank notepad file and type the following:
- #!/bin/sh
- fpp -P playme
- Save it as a .sh file on your computer
- Go to the file manager in FPP and upload your script file. Go to the "Scripts" tab and make sure it is there
- Under Status/Control go to Events
- Create a new event. Event ID 1/1, Event name whatever, Effect Sequence NONE, Event Script
- Go under Input/Output Setup and click GPIO triggers
- Toggle the pin your button is attached to. If it will go low when you press the button then put the event on the Falling option, if it is active high then put the event on Rising.
- Click the Reboot button by the warning it pops up after you make all the changes
After doing all this, you should be able to press the button to get your show to start. Woohoo!
However, this method has some limitations. If you press the button again while the playlist is going, it either 1) won't do anything or 2) will crash FPP and refuse to do anything with your button until you reboot it. So if you're just using a button as a dramatic way play your show on command, the above method will be all you need.
If you need something more, continue to the next step
Step 4: A More Robust Script
Below is the script that I eventually arrived at. You can view the script on Github here: [Gist.Github]
- If someone presses the button during “night” hours it will play Tiger Rag (my Song1) and then go to the standby sequence which loops infinitely.
- If the button is pressed while Tiger Rag is playing then it starts my second song, Hallelujah, and then will go to the standby sequence indefinitely.
- But if someone presses the button during daytime or very late at night it will play Tiger Rag once and then turn all the lights off.
This allows the button to work at any time of day but the lights don’t have to be on all the time. It also allows for multiple songs to be played from 1 button by identifying which song is currently playing, ending that song, and playing the "next" song.
You can find more resources for scripting in FPP here: https://github.com/FalconChristmas/fpp-scripts
For more complicated logic just google “bash script ____” where underscore is what you’re trying to do. You can test your scripts using the FPP Shell (username fpp password falcon) The basic commands are as follows.
Pay attention to capitalization!!
- Capital -P will play a playlist once, lowercase -p will repeat it.
- fpp -v 66 Set volume to 66%
- fpp -c stop Stop the show immediately
- fpp -C stop This might be stop show gracefully
- fpp -p thisPlaylistName Plays thisPlaylistName on repeat (so the intro song plays once, then the Main stuff will be repeated indefinitely.
- fpp -P thisPlaylistName Plays thisPlaylistName once
- eventScript "${MEDIADIR}/scripts/${thisScriptVariable}" Runs a script. In the case on the left it works for if you have your script name saved into a variable somewhere above, like thisScriptVariable=”PlayTheSong.sh”
Step 5: (Optional) Faceplate for the Button
I have access to a laser cutter at Clemson through the Makerspace, so I quickly sketched up a design to cut+etch. There's a hole in the middle for my button, the words say "Push Me" in a Christmas font, and a snowflake around the button. I spray painted some wood white and then covered it in masking tape (so that the laser cutter doesn't scorch parts I don't want etched). The file I used is attached.