A random mess of LEDs
No structure
No order
Complete chaos
Order has emerged.
We have a discernible geometric pattern on our leds.
How does this work?
Let's have a look under the hood.
We're using an ESB 32 camera board
With some simple image processing
and a string of WS2811 addressable RGB LEDs.
Wiring up the addressable LEDs is pretty straightforward
they just require a power supply and data connection.
Data is sent to the first LED on its data pin
it keeps the bits that are meant for it and sends the remaining data on to the next LED.
This happens down the chain of LEDs and until of a none left.
To program the ESP 32 we need a USB to UART board.
Once we've downloaded the initial sketch
we can switch over to over-the-air updates which makes things quite a bit more convenient.
To talk to the addressable LEDs we also need a level shifter
the ESP board can only output 3.3 volts and the addressable LEDs
require 5 volts to work reliably.
There are many ways to do level shifting
Adafruit have several boards that you can use and I've got a mosfet driver
left over from another project that I'm going to use.
Let's quickly run through the circuit for driving the LEDs.
I've decided to have two separate power supplies
One for the LEDs and one for the ESP 32.
The LEDs require a fair amount of power
and the ESP cam is quite sensitive to voltage drops and seems to brown out very easily.
I've also added a couple of large capacitors across each power supply.
We need to make sure there is a common ground between both power supplies
so we connect the two ground pins.
For the level shifting I'm using my FET driver and I'm also adding a small
decoupling capacitor to this chip.
Finally we can add the cables for the ESP32 and for the LEDs.
Connecting the power ground and data lines
That's our circuit complete let's talk about the software.
To make the whole thing work we need to know where each LED is.
To do this we apply some simple image processing.
For each LED in the string we capture a frame with all the LEDs off.
We then light one individual LED and capture another frame.
These two frames are compared
and the location of the LED is determined by finding the part of the
image with the largest difference.
Repeating this lets us work out the
approximate positions for each LED in the string.
To display an image on the LEDs we create a frame buffer
and draw out required image into that frame buffer.
we then run through each LED and take the color that the LED should be
given its position on the image.
To provide user interface to the board
I've built a very simple web interface that is served from the ESP 32 cam device.
We can capture a frame from the sensor
We can tell the system to recalibrate the LEDs
and we can also pause and resume the animation sequence.
All the code for the project is on GitHub.
Let me know if you have any comments or suggestions.
and please do hit the subscribe button
It's the only way I have of knowing if you like these videos and want more.
Thanks for watching and I'll see you in the next video!