lightshowpi documentation¶
Blinky lights for Christmas, powered by Raspberry Pi.
Input devices¶
(Methods to get audio into the system)
Music stored locally on the RPi and run in sequence, or randomy
Connect to your wifi network and sync to AirPlay on devices on your network
Connect a USB audio input card and match lighting to analog audio from any device
Ways to control LightShowPi¶
Other resources¶
Documentation source (bitbucket)
Installation¶
Introduction¶
LSP is installed from a GIT repo on bitbucket. Both Python 2.x and Python 3.x versions exist.
Python 2¶
# Install git (if you don't already have it)
sudo apt-get install git-core
# Clone the repository to /home/pi/lightshowpi
cd ~
git clone https://togiles@bitbucket.org/togiles/lightshowpi.git
# Grab the stable branch
cd lightshowpi
git fetch && git checkout stable
Python 3¶
You must use the Python 3.x branch in the following cases:
- Raspberry Pi OS (formerly known as Raspbian) ‘Buster’ or later
- For RaspberryPi 4
sudo apt-get --allow-releaseinfo-change update
sudo apt-get upgrade
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
sudo apt-get install git-core
git clone https://togiles@bitbucket.org/togiles/lightshowpi.git
cd lightshowpi
git fetch && git checkout python3
sudo ./install.sh
sudo reboot
Analog audio¶
The system can follow allow with any analog audio, such as the headphone output from a PC/phone or from the Monitor output of your amplifier. To do this, you will need to add an anaolgi input (mic input) to:
- Connect an external audio in sound card to the RaspberryPi
- Determine which analog input is the correct one (the RPi may detect multiple audio devices)
- Update overrides.cfg with the correct device
Soundcards¶
something about USB sound cards
Use toolsfind_audio.py Set device ID as 3
Note, if you sometimes connect an external monitor HDMI wih internal speakers, then the sound device list will renumerate, so the USB sound card you used while headless may now be a different number.
sample 1: tool output running headless
[1, 2]
sample 2: Same output, but now with HDMI monitor connected.
[1, 2, 3]
Note the USB audio device is now device 3.
The configuration file¶
The configuration file sets everything. Which pins you are using, where your playlist is saved etc etc.
- Make a copy of defaults.cfg
- Save as overrides.cfg
- Open overrides.cfg in notepad++ or similar.
Micro Web UI for LightShowPi¶
A very simple web page for controlling LightShowPi
To use :
On your Pi,
Go to your base lightshowpi directory, typically /home/pi/lightshowpi > cd $SYNCHRONIZED_LIGHTS_HOME or > cd /home/pi/lightshowpi
Run the web server from the command line type > start_microweb
If at any time you wish to stop Microweb, at the command line type > stop_microweb
On your PC or mobile device,
Open a browser to the following http://<PI>/ where <PI> is the IP address of your Pi
To run microweb at startup, the preferred method is:
> sudo crontab -e
Then add the following lines:
# set enviroment variable # you might need to adjust the path if you did not install # lightshowpi to the default directory SYNCHRONIZED_LIGHTS_HOME=/home/pi/lightshowpi
@reboot $SYNCHRONIZED_LIGHTS_HOME/bin/start_microweb >> $SYNCHRONIZED_LIGHTS_HOME/logs/microweb.log 2>&1
- “Play Next” will only work for more than one song defined in playlist mode.
All other modes will only restart the defined configuration.
There are four pages available, main, playlist, tools, and configuration Main Page - Main controls for lights and starting the show. Volume control.
- navigation to other pages by icon or button
- Playlist Page - Songs available in your defined playlist.
- clicking a song will start it immediately
- next song to be played is highlighted
- Tools Page - Shutdown/Reboot and individual channel operation
- this page takes slightly longer to load
- Settings Page - View or Select your config file
- create any config file in the format overrides*.cfg in your config/ directory and it will be available to use. * can be any character or characters, but you must start with overrides and end with .cfg. microweb will use that file for all operations until changed.
- edit .playlist files reorder files use selected files
- upload music files to .playlist directory
Have fun. Ken B
Raspberry Pi pin outputs¶
LightshowPi uses WiringPi standards. http://wiringpi.com/pins/
WiringPi/LightshowPi pin | RPi Name | Physical pin |
---|---|---|
0 | GPIO0 | 11 |
1 | GPIO1 | 12 |
2 | GPIO2 | 13 |
3 | GPIO3 | 15 |
4 | GPIO4 | 16 |
5 | GPIO5 | 18 |
6 | GPIO6 | 22 |
7 | GPIO7 | 7 |
8 | SDA | 3 |
9 | SCL | 5 |
10 | CE0 | 24 |
11 | CE01 | 26 |
12 | MOSI | 19 |
13 | MISO | 21 |
14 | SCLK | 23 |
15 | TXD | 8 |
16 | RXD | 10 |
17 | GPIO8 | Sec 3 |
18 | GPIO9 | Sec 4 |
19 | GPIO10 | Sec 5 |
20 | GPIO11 | Sec 6 |
Arduino connectivity¶
Thanks to Maniacal Labs for making the open source BiblioPixel Library and the firmware to the AllPixel open source as well.
To setup your Arduino for use with lightshowpi you will need to get some information about your Arduino.
First you will need your device address. Getting the address from the command line is simple Without your Arduino pluged in type in the command ls /dev/tty*
example output pi@raspberrypi:~/lightshowpi/py $ ls /dev/tty* /dev/tty /dev/tty17 /dev/tty26 /dev/tty35 /dev/tty44 /dev/tty53 /dev/tty62 /dev/tty0 /dev/tty18 /dev/tty27 /dev/tty36 /dev/tty45 /dev/tty54 /dev/tty63 /dev/tty1 /dev/tty19 /dev/tty28 /dev/tty37 /dev/tty46 /dev/tty55 /dev/tty7 /dev/tty10 /dev/tty2 /dev/tty29 /dev/tty38 /dev/tty47 /dev/tty56 /dev/tty8 /dev/tty11 /dev/tty20 /dev/tty3 /dev/tty39 /dev/tty48 /dev/tty57 /dev/tty9 /dev/tty12 /dev/tty21 /dev/tty30 /dev/tty4 /dev/tty49 /dev/tty58 /dev/ttyAMA0 /dev/tty13 /dev/tty22 /dev/tty31 /dev/tty40 /dev/tty5 /dev/tty59 /dev/ttyprintk /dev/tty14 /dev/tty23 /dev/tty32 /dev/tty41 /dev/tty50 /dev/tty6 /dev/tty15 /dev/tty24 /dev/tty33 /dev/tty42 /dev/tty51 /dev/tty60 /dev/tty16 /dev/tty25 /dev/tty34 /dev/tty43 /dev/tty52 /dev/tty61 pi@raspberrypi:~/lightshowpi/py $
Now plug in your arduino and issue the same command
pi@raspberrypi:~/lightshowpi/py $ ls /dev/tty* /dev/tty /dev/tty17 /dev/tty26 /dev/tty35 /dev/tty44 /dev/tty53 /dev/tty62 /dev/tty0 /dev/tty18 /dev/tty27 /dev/tty36 /dev/tty45 /dev/tty54 /dev/tty63 /dev/tty1 /dev/tty19 /dev/tty28 /dev/tty37 /dev/tty46 /dev/tty55 /dev/tty7 /dev/tty10 /dev/tty2 /dev/tty29 /dev/tty38 /dev/tty47 /dev/tty56 /dev/tty8 /dev/tty11 /dev/tty20 /dev/tty3 /dev/tty39 /dev/tty48 /dev/tty57 /dev/tty9 /dev/tty12 /dev/tty21 /dev/tty30 /dev/tty4 /dev/tty49 /dev/tty58 /dev/ttyACM0 /dev/tty13 /dev/tty22 /dev/tty31 /dev/tty40 /dev/tty5 /dev/tty59 /dev/ttyAMA0 /dev/tty14 /dev/tty23 /dev/tty32 /dev/tty41 /dev/tty50 /dev/tty6 /dev/ttyprintk /dev/tty15 /dev/tty24 /dev/tty33 /dev/tty42 /dev/tty51 /dev/tty60 /dev/tty16 /dev/tty25 /dev/tty34 /dev/tty43 /dev/tty52 /dev/tty61
There is a new entry in this case it’s /dev/ttyACM0 For one of my clones it /dev/ttyUSB0 So yours may vary depending on what your device is.
The next thing that we need is the hardware ID of your device in “VID:PID” form The command for that is lsusb
pi@raspberrypi:~/lightshowpi/py $ lsusb Bus 001 Device 025: ID 2341:0043 Arduino SA Uno R3 (CDC ACM) Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
That one was easy it says Arduino right on it VID:PID for the above is 2341:0043
pi@raspberrypi:~/lightshowpi/py $ lsusb Bus 001 Device 026: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub pi@raspberrypi:~/lightshowpi/py $
For this clone it not as clear 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
So again you might want to run lsusb without the Arduino pluged in then with to see the difference.
So that is how you get your device address and hardware ID for the lightshowpi config.
So now we need to burn our sketch to the Arduino, I’ll leave that for you.
But there are a few variables that you have an option of changing. They are all optionally defined in the global.h file.
SPI_DATA, SPI_CLOCK, ONEWIREPIN, rebootPin
The only reason to change the ONEWIREPIN is if you are using it for something else
The rebootPin, again the only reason to change it is if you are using that pin for something else.
For SPI_DATA and SPI_CLOCK see the notes at the bottom for modifications. Doing so is not nessary, if your Arduino has an ICSP header then you can use that and not have to change a thing. Included is ICSPHeader.jpg
Now that our sketch is loaded on the Arduino all we have to do is hook up the wires
- connect a jumper from the rest pin to pin 15
- connect your led strip data line to pin 4 on the ICSP header for spi controled strips or to your Arduinos pin 2 for led strips that do not have a clock line
- if your strip has a clock line the connect it to pin 3 on the ICSP header
- connect your led strips to their power source. Use an external source, do not power them from you Arduino
- run a common ground from the led strip or external power supply to any of the ground pins on the arduino. pin 6 on the ICSP header is a ground for example.
- use a usb cable hook you RPI to your Arduino.
global.h notes :
// define pins use with your arduino
// ONEWIREPIN is for use with led strips that do not have a clock line // just a data line. #define ONEWIREPIN 2
// Data and Clock pins // if you use the ICSP header you do not need to set these values. // If you need/want to you can set them to something else here. // Arduino Nano, Pro, Pro Mini, Micro, Uno, Duemilanove //#define SPI_DATA 11 //#define SPI_CLOCK 13 //arduino Mega //#define SPI_DATA 51 //#define SPI_CLOCK 52
// pin 15 is A0 on an Uno, on the Mega it is RX3. // you can change this to any free pin that you have #define rebootPin 15
Apple AirPlay support¶
I have no idea how this works.
Playlists¶
Playlists are the easiest way to get started with lightshowpi.
# Copy files across the th pi under the /music folder
# run tool/adsfsad.Playlists
# start lightshow