Sound reactive LED strip using Python and Arduino.
Inspired by https://robtrevino.com/2019/06/23/using-a-rgb-led-strip-as-an-audio-visualizer/. I took his code and made my own version of it, it is not perfect but it works. So feel free to play with it and improve it !
- Arduino and Arduino IDE
- LED Strip compatible with Arduino's FastLED/Neopixel library (I'm using Adafruit Neopixel 144 LEDS - 1m LED Strip)
- Cygwin with developper tools and python (You can use Microsoft Visual Studio but i haven't tried)
- Pyaudio with Portaudio https://github.com/intxcc/pyaudio_portaudio
You first need to install Cygwin with the basic developper tools and also Python (I'm using Python version 3.6.9) Then install Pyaudio
If pip is not installed you should get it by downloading this.
Then in Cygwin go to the directory where you downloaded get-pip.py and enter the following command: pythonX get-pip.py
where 'X' is your python version.
To run the python script you may have to install
- Pyserial
- Numpy
- Colour
Simply use pip install [package name]
See this link to wire the LED strip to your Arduino
The Arduino code is using PIN 6 to command the LED strip.
Cygwin is showing serial port as dev\ttySX
where is X
is the COM port of your Arduino with an offset of 1.
So for example if your Arduino is using COM3, go to the python script line 6 and change it to
port = '\dev\ttyS2'
You can also use \dev\com3
Plug in your Arduino with the code on it then run the python script. It will ask you to select a device, select the device you use for the sound and you're done ! Enjoy !
With Cygwin there's an issue where you will have to first open the Serial monitor in Arduino IDE when Arduino is plugged in for the first time and then run the script. Otherwise it will not be able to connect to the serial port.