LED Butterfly Display Reveal
LED Butterfly Display Reveal
What I wanted to learn, and why it interested me: Although we briefly did wiring with the LED light in our learning modules, I wanted to learn more about using LEDS to program creative outputs. I want to learn how to make designs and visual patterns with light strips, so I decided to pursue this element.
Final outcome: An LED grid that displays an image of a butterfly. Taking the potentiometer value as input, the progression of the image display reveals the full image when the potentiometer reaches 1000.
Images of final creative/exploratory output
Picture of butterfly fully displayed when potentiometer value > 1000
Video demo of LED grid in use
Process images from development towards creative/exploratory output
Soldered power, ground, and signal to a strip that contains 8 LEDs to test out the strip for technical training.
Connected 8 individual LED strips to form a grid. Soldered power and ground to each strip. Soldered out and input between the 8 strips to connect them
Final Grid connected and wired up.
All LED lights led up on the grid
Progression of butterfly display as potentiometer value increases
Progression 2
Progression 3
Progression 4
Turns blue after value > 1000
Process and reflection:
First, I did the technical training for LEDs by taking a strip of 8 LEDs and experimenting with them. I explored the library that was used to light up the LED strips and programmed the code to make my strip show a sequence of light patterns. I programmed the LEDs to show a pattern of blue and purple, where odd LEDs are purple and even LEDs are blue, followed by a reverse where odd LEDs are blue and even LEDs are purple.
Then, got to work by building the physical grid of the LED grid by taking 8 strips containing 7 LED lights. The output of a strip had to be soldered and wired to the output of the next strip. The power and ground of each strip also had to be soldered and wired to the ground and power of the Arduino. During my first round of wiring and soldering, I messed up on the wiring because I did not connect the power and grounds of each strip efficiently, as the holes of the protoboard that I soldered the wires to were not connected. Thus, I had to connect the ends of each power and ground together. After an attempt to do that, the wiring turned into a mess, so I had to redo the soldering and wiring. By using a different protoboard, I was able to connect the power and ground wires more easily. I learned that the wiring needs to be planned and mapped out meticulously before soldering, because a well-planned physical wire connection can prevent many hardware problems.
Lastly, the last part was the software portion of the project, where the commands to light up the LED needed to be programmed. After experimenting with the grid, I mapped out the pixels of the image that I wanted to display on the LED grid. I sectioned the image into multiple arrays, so each portion would be displayed depending on the input value from the potentiometer.
Technical details
Electrical Schematic - 48 LEDS connected in a grid
/*
Pin mapping:
Arduino pin | role | description
----------- | ----- | ------------
2 output transmits color data into LED strip
A0 input takes in potentiomonitor value
*/
#include <PololuLedStrip.h>
//Setting the constant values
const int LEDSTRIPPIN = 2; // pin to connect strip to
const int NUMLEDS = 48; // number of LEDs in the strip
const int POTPIN = A0;
// Create an ledStrip object and specify the pin it will use.
PololuLedStrip<LEDSTRIPPIN> ledStrip;
// Create an array for holding the colors (3 bytes per color).
rgb_color testing[NUMLEDS];
rgb_color colors[NUMLEDS];
rgb_color butterfly[NUMLEDS];
// "rgb_color".
rgb_color black = rgb_color(0, 0, 0);
rgb_color white = rgb_color(255, 255, 255);
rgb_color red = rgb_color(255, 0, 0);
rgb_color orange = rgb_color(255, 75, 0);
rgb_color yellow = rgb_color(255, 255, 0);
rgb_color green = rgb_color(0, 255, 0);
rgb_color blue = rgb_color(0, 0, 255);
rgb_color indigo = rgb_color(75, 0, 130);
//array containing the points of butterfly image progressions
const uint8_t bf0[] = {14, 15};
const uint8_t bf1[] = {7, 10, 0, 5, 6, 11};
const uint8_t bf2[] = {12, 18, 25, 17, 23, 28};
const uint8_t bf3[] = {26, 27, 36, 41};
const uint8_t bf4[] = {42, 37, 32, 47, 40, 33};
void setup() {
Serial.begin(9600);
pinMode(POTPIN, INPUT);
//turn every LED white
for(int i = 0; i < NUMLEDS; i++){
testing[i] = white;
}
ledStrip.write(testing, NUMLEDS);
delay(500);
// turn every LED red
for (int i = 0; i < NUMLEDS; i++){
testing[i] = red;
}
ledStrip.write(testing, NUMLEDS);
delay(500);
}
void loop() {
//read potentiometer value
int potVal = analogRead(POTPIN);
Serial.println(potVal);
for (int i = 0; i < NUMLEDS; ++i) butterfly[i] = black;
//when value reaches the max, the entire image will turn blue
if (potVal > 1000){
for (uint8_t v : bf0) butterfly[v] = blue;
for (uint8_t v : bf1) butterfly[v] = blue;
for (uint8_t v : bf2) butterfly[v] = blue;
for (uint8_t v : bf3) butterfly[v] = blue;
for (uint8_t v : bf4) butterfly[v] = blue;
ledStrip.write(butterfly, NUMLEDS);
delay(200);
return;
}
//first section of buttefly image
if (potVal > 10){
for (uint8_t value: bf0){
butterfly[value] = indigo;
}
}
//second section of butterfly image
if (potVal > 100){
for (uint8_t value: bf1){
butterfly[value] = indigo;
}
}
//third section of butterfly image
if (potVal > 250){
for (uint8_t value: bf2){
butterfly[value] = indigo;
}
}
//fourth section of butterfly image
if (potVal > 800){
for (uint8_t value: bf3){
butterfly[value] = indigo;
}
}
//fifth section of butterfly image
if (potVal > 900){
for (uint8_t value: bf4){
butterfly[value] = indigo;
}
}
ledStrip.write(butterfly, NUMLEDS);
delay(30);
}