Day 1: Creating the Code for NeoPixels
After reading two articles about Seeed XIAO RP2040, I started to generated code for NeoPixels on LED Strip Effect Generator. This project is able to let me know how to generate the code for the infinity mirror that I am going to make later. There was a strip on the screen once I open the website.
I opened the strip settings and changed the LEDs Quantity to 36.
I clicked on "Add Effect" and chose the "Rainbow Option". There was a button called "Color" and I dragged the slider to bind the colors together to make colors other than blue ,green and red. At last, I clicked on "Generate Code" and got the code below.
Code:
#include <Adafruit_NeoPixel.h>
class Strip
{
public:
uint8_t effect;
uint8_t effects;
uint16_t effStep;
unsigned long effStart;
Adafruit_NeoPixel strip;
Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : strip(leds, pin, striptype) {
effect = -1;
effects = toteffects;
Reset();
}
void Reset(){
effStep = 0;
effect = (effect + 1) % effects;
effStart = millis();
}
};
struct Loop
{
uint8_t currentChild;
uint8_t childs;
bool timeBased;
uint16_t cycles;
uint16_t currentTime;
Loop(uint8_t totchilds, bool timebased, uint16_t tottime) {currentTime=0;currentChild=0;childs=totchilds;timeBased=timebased;cycles=tottime;}
};
Strip strip_0(36, 2, 36, NEO_GRB + NEO_KHZ800);
struct Loop strip0loop0(2, false, 1);
struct Loop strip0loop00(0, false, 1);
//[GLOBAL_VARIABLES]
void setup() {
//Your setup here:
strip_0.strip.begin();
}
void loop() {
//Your code here:
strips_loop();
}
void strips_loop() {
if(strip0_loop0() & 0x01)
strip_0.strip.show();
}
uint8_t strip0_loop0() {
uint8_t ret = 0x00;
switch(strip0loop0.currentChild) {
case 0:
ret = strip0_loop0_eff0();break;
case 1:
ret = strip0_loop00();break;
}
if(ret & 0x02) {
ret &= 0xfd;
if(strip0loop0.currentChild + 1 >= strip0loop0.childs) {
strip0loop0.currentChild = 0;
if(++strip0loop0.currentTime >= strip0loop0.cycles) {strip0loop0.currentTime = 0; ret |= 0x02;}
}
else {
strip0loop0.currentChild++;
}
};
return ret;
}
uint8_t strip0_loop0_eff0() {
// Strip ID: 0 - Effect: Rainbow - LEDS: 36
// Steps: 60 - Delay: 20
// Colors: 3 (255.0.0, 106.255.0, 0.83.255)
// Options: rainbowlen=60, toLeft=true,
if(millis() - strip_0.effStart < 20 * (strip_0.effStep)) return 0x00;
float factor1, factor2;
uint16_t ind;
for(uint16_t j=0;j<36;j++) {
ind = strip_0.effStep + j * 1;
switch((int)((ind % 60) / 20)) {
case 0: factor1 = 1.0 - ((float)(ind % 60 - 0 * 20) / 20);
factor2 = (float)((int)(ind - 0) % 60) / 20;
strip_0.strip.setPixelColor(j, 255 * factor1 + 106 * factor2, 0 * factor1 + 255 * factor2, 0 * factor1 + 0 * factor2);
break;
case 1: factor1 = 1.0 - ((float)(ind % 60 - 1 * 20) / 20);
factor2 = (float)((int)(ind - 20) % 60) / 20;
strip_0.strip.setPixelColor(j, 106 * factor1 + 0 * factor2, 255 * factor1 + 83 * factor2, 0 * factor1 + 255 * factor2);
break;
case 2: factor1 = 1.0 - ((float)(ind % 60 - 2 * 20) / 20);
factor2 = (float)((int)(ind - 40) % 60) / 20;
strip_0.strip.setPixelColor(j, 0 * factor1 + 255 * factor2, 83 * factor1 + 0 * factor2, 255 * factor1 + 0 * factor2);
break;
}
}
if(strip_0.effStep >= 60) {strip_0.Reset(); return 0x03; }
else strip_0.effStep++;
return 0x01;
}
uint8_t strip0_loop00() {
uint8_t ret = 0x00;
switch(strip0loop00.currentChild) {
}
if(ret & 0x02) {
ret &= 0xfd;
if(strip0loop00.currentChild + 1 >= strip0loop00.childs) {
strip0loop00.currentChild = 0;
if(++strip0loop00.currentTime >= strip0loop00.cycles) {strip0loop00.currentTime = 0; ret |= 0x02;}
}
else {
strip0loop00.currentChild++;
}
};
return ret;
}
Video of the simulation on the LED Strip Effect Generator
Using the Code in TinkerCAD
I created a new circuit and added a Arduino Uno R3 and 36 Neopixels to simulate the light effect. I connected the GND, 5V, and DIN pins of the neopixels onto the corresponding pins on the Arduino Uno R3 with wires according to the pins listed in my code. Then I copied and pasted the code into the Code section and my simulation was ready to work.
Video of the simulation in TinkerCAD
The actual effect appearing on the neopixels
Day Two: Modify my code to change the effect
The effect for the first time was not really what I want. So I started over and generate the code once again using the LED effect generator. I then uploaded the code and had the effect that I wanted.
The new-generated Code
#include <Adafruit_NeoPixel.h>
class Strip
{
public:
uint8_t effect;
uint8_t effects;
uint16_t effStep;
unsigned long effStart;
Adafruit_NeoPixel strip;
Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : strip(leds, pin, striptype) {
effect = -1;
effects = toteffects;
Reset();
}
void Reset(){
effStep = 0;
effect = (effect + 1) % effects;
effStart = millis();
}
};
struct Loop
{
uint8_t currentChild;
uint8_t childs;
bool timeBased;
uint16_t cycles;
uint16_t currentTime;
Loop(uint8_t totchilds, bool timebased, uint16_t tottime) {currentTime=0;currentChild=0;childs=totchilds;timeBased=timebased;cycles=tottime;}
};
Strip strip_0(36, 2, 36, NEO_GRB + NEO_KHZ800);
struct Loop strip0loop0(1, false, 1);
//[GLOBAL_VARIABLES]
void setup() {
//Your setup here:
strip_0.strip.begin();
}
void loop() {
//Your code here:
strips_loop();
}
void strips_loop() {
if(strip0_loop0() & 0x01)
strip_0.strip.show();
}
uint8_t strip0_loop0() {
uint8_t ret = 0x00;
switch(strip0loop0.currentChild) {
case 0:
ret = strip0_loop0_eff0();break;
}
if(ret & 0x02) {
ret &= 0xfd;
if(strip0loop0.currentChild + 1 >= strip0loop0.childs) {
strip0loop0.currentChild = 0;
if(++strip0loop0.currentTime >= strip0loop0.cycles) {strip0loop0.currentTime = 0; ret |= 0x02;}
}
else {
strip0loop0.currentChild++;
}
};
return ret;
}
uint8_t strip0_loop0_eff0() {
// Strip ID: 0 - Effect: Rainbow - LEDS: 36
// Steps: 60 - Delay: 20
// Colors: 3 (255.80.0, 0.255.35, 54.46.255)
// Options: rainbowlen=60, toLeft=true,
if(millis() - strip_0.effStart < 20 * (strip_0.effStep)) return 0x00;
float factor1, factor2;
uint16_t ind;
for(uint16_t j=0;j<36;j++) {
ind = strip_0.effStep + j * 1;
switch((int)((ind % 60) / 20)) {
case 0: factor1 = 1.0 - ((float)(ind % 60 - 0 * 20) / 20);
factor2 = (float)((int)(ind - 0) % 60) / 20;
strip_0.strip.setPixelColor(j, 255 * factor1 + 0 * factor2, 80 * factor1 + 255 * factor2, 0 * factor1 + 35 * factor2);
break;
case 1: factor1 = 1.0 - ((float)(ind % 60 - 1 * 20) / 20);
factor2 = (float)((int)(ind - 20) % 60) / 20;
strip_0.strip.setPixelColor(j, 0 * factor1 + 54 * factor2, 255 * factor1 + 46 * factor2, 35 * factor1 + 255 * factor2);
break;
case 2: factor1 = 1.0 - ((float)(ind % 60 - 2 * 20) / 20);
factor2 = (float)((int)(ind - 40) % 60) / 20;
strip_0.strip.setPixelColor(j, 54 * factor1 + 255 * factor2, 46 * factor1 + 80 * factor2, 255 * factor1 + 0 * factor2);
break;
}
}
if(strip_0.effStep >= 60) {strip_0.Reset(); return 0x03; }
else strip_0.effStep++;
return 0x01;
}
Day 3: Soldering
Soldering on Xiao Seeed RP2040
I first soldered the three wires on to the neo pixels. The red wire matched with +5V pin. The black wire always matched with GND pin. The yellow one matched with the DIN pin.
Then I got two wires soldered onto the Seeed, following the right pin showing on the scond picture. The black one was attached to GND pin. The red one was attached to the 5V pin
We first used a Barrel Jack to regulate the voltage in the wire because the Seeed only needs 3V and the excessive voltage will fry the Seeed. We put the two black wires into the negative pin and the red wires into the positive pin.
The next day, we found out that the Xiao Seeed RP2040 actually regulates the voltage it self which means we don't need the 5V regulator anymore. So we took the regulator off and soldered the wires of the same color together. Then we use the black shrinking wraps to protect us from condcuting electricity.
Video of the final effect on the actual neopixels
Day 4: Making Wood Frame
Cutting the wood to make the frame of the infinity mirror
When we first cut the wood, we used the 45 degrees-angle blade to cut the end of the wood so that it would have the shape we wanted. These two videos show me cutting the two ends of the wood respectively.
We used the same 45 degree blade to cut the long wood stick into 4 pieces. Then we use sandpaper to make the surfaces smooth. Each wood piece is about 18.9 cm x 1.89cm x 6.3cm. The short side is about 15.2cm each wood piece.
Final wood pieces
Cutting the grooves on the wood pieces
We first cut the narrow grooves on the wood pieces. Each wood piece has two grooves. We need the grooves to hold the two mirrors. We used the 90 degrees blade to cut the two grooves on each wood piece. I used the Saw Stop table saw to press hard on the wood piece and tried to fix it, so the grooves would be straight and firm. I accidently cut one groove on the longer surface on one of the wood pieces. But it turned out to be unique.
After finishing the narrow grooves on the wood pieces, we started to create the wide grooves used to stick the neopixels onto on a different machine. We also cut the groove on the shorter surfaces of the wood pieces. I also used the table saw to press the wood pieces against the blade and a groove on each side.
Final wood pieces with the grooves on
Glue the wood pieces together
On the other day, we glued three wood pieces together. I first used the tape to tape the wood pieces together so that the grooves were aligned with others. Then I applied wood glue onto the connecting side of the wood pieces and press the wood pieces against each other and held them for a while so they stick with each other.
Drilling a Hole on the wood piece
We need a hole on the one of the wood pieces to make the wires coming out. We used the router to drill the hole on the wood piece. One of my hands pressed against the wood piece on the platform so that it wouldn't move. My other hand was pressing down the handle to make the drilling tool move.
Final wood piece after drilling a hole on
Making the Mirror
After out teacher helped us cut the mirror pieces off, we just needed to make the mirror film stick onto the clear piece to a real mirror. We used the squeegee or the scraper to help make the film stick on the plastic piece firmly and without bubbles on it.
I plugged the mirror that I just completed into the three-wood-piece frame. Then I sticked the neopixels onto the wood frame.
Video with only one mirror piece on
Putting Another Mirror piece on
We stick another film onto the dark mirror piece and plugged it into the wood frame. Then I glued the fourth piece of the wood frame and finished the final infinity mirror.
Final Product of My Infinity Mirror
Problem Encountered
Making the Mirror
The first time when we tried to put mirror film on to the clear mirror piece, we found that we were not able to stick the film onto the clear piece. We tried to use the hot press in the art classroom to try to use the heat to make the film stick on. However, it didn't work very well. The film still didn't want to stay on the clear piece. On the next day, we figured out that there was another film on the mirror film. We needed to peel it off so that the mirror film would stick onto the clear piece immediately.
Adding Neopixels
When I stick the string of the neopixels onto the wood frame, I found out that the neopixels were not enough to cover the whole track. I had to solder two more neopixels on. I also needed to modify my code to make the two additional neopixels light up.