Skip to content

Real-time LED strip music visualization using a Raspberry Pi 3 on a handcart

License

Notifications You must be signed in to change notification settings

andrealbers/Handcart-with-audio-visualization

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Audio Reactive LED Strip

Real-time LED strip music visualization using a Raspberry Pi 3 B+ used for a Handcart. Watch Video1/2 for example.

Raspberry Pi

You cannot power the LED strip using the Raspberry Pi GPIO pins, you need to have an external 5V power supply.

The connections are:

  • Connect GND on the power supply to GND on the LED strip and GND on the Raspberry Pi (they MUST share a common GND connection)
  • Connect +5V on the power supply to +5V on the LED strip
  • Connect Pin 18 (PWM GPIO) on the Raspberry Pi to the data pin on the LED Strip.

Installing the Python dependencies

Install python dependencies using apt-get

sudo apt-get update
sudo apt-get install python-numpy python-scipy python-pyaudio qt5-default pyqt-dev pyqt5-dev-tools

Install ws281x library

sudo apt-get install build-essential python-dev git scons swig
git clone https://github.com/jgarff/rpi_ws281x.git
cd rpi_ws281x
scons
cd python
sudo python setup.py install

Audio device configuration

For the Raspberry Pi, a USB audio device needs to be configured as the default audio device.

Create/edit /etc/asound.conf

sudo nano /etc/asound.conf

Set the file to the following text

pcm.!default {
    type hw
    card 1
}
ctl.!default {
    type hw
    card 1
}

Next, set the USB device to as the default device by editing /usr/share/alsa/alsa.conf

sudo nano /usr/share/alsa/alsa.conf:

Change

defaults.ctl.card 0
defaults.pcm.card 0

To

defaults.ctl.card 1
defaults.pcm.card 1

Test the LED strip

  1. cd rpi_ws281x/python/examples
  2. sudo nano strandtest.py
  3. Configure the options at the top of the file. Enable logic inverting if you are using an inverting logic-level converter. Set the correct GPIO pin and number of pixels for the LED strip.
  4. Run example with 'sudo python strandtest.py'

Configure the visualization code

In config.py, set the device to 'pi' and configure the GPIO, LED and other hardware settings. If you are using an inverting logic level converter, set LED_INVERT = True in config.py. Set LED_INVERT = False if you are not using an inverting logic level converter (i.e. connecting LED strip directly to GPIO pin).

Audio Input

  • Audio cable connected to the audio input jack (requires USB sound card on Raspberry Pi)

Running the Visualization

Once everything has been configured, run visualization.py to start the visualization. The visualization will automatically use your default recording device (microphone) as the audio input.

There is a setting to enable/disable the GUI display in config.py.

License

This project was developed by Scott Lawson and is released under the MIT License.

About

Real-time LED strip music visualization using a Raspberry Pi 3 on a handcart

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%