Update 11/22/2013: Thanks to everyone who voted for this project in the Microcontroller Contest! It was one of three first-prize winners.
Update 9/17/2013: Thanks to everyone who voted for this project in the Arduino contest (I was one of ten "second prize" winners)! If you want to try this project with an addressable LED strip instead of an analog strip, check out the Rainbow Jar project (also an Arduino contest winner).
This is my take on a combination of two classic projects: RGB LED control with an Arduino, and an Infinity Mirror. It's an RGB LED infinity mirror that lets you toggle between an adjustable-speed color-fade mode and a direct-control mode where you individually set the red, green, and blue LED brightness levels.
The primary inspiration for this particular project comes from this infinity mirror Instructable and Adafruit's RGB LED Strip tutorial, but there are many more quality resources out there on both projects.
I've done my best to gear this project towards newbies by providing an exact list of materials I used and the exact procedure that I followed. One recurring theme I've noticed in comment sections for other infinity mirrors is a lack of links to specific parts (e.g. exactly what type of LEDs or LED strips were used, what power supply, where to buy the mirrors, the enclosure, etc). Clearly, if you know what you're doing and want to spend more (or less) money to design a slightly different mirror, you can adjust your materials as needed, use a different Arduino board, etc. You can skip the Arduino entirely and make a pretty simple, cheap infinity mirror if you want (just search Instructables for "infinity mirror" and you'll find a few), or go crazy and spend hundreds if not thousands of dollars (search YouTube for "infinity mirror table" and you'll get the idea).
On to the materials list. Remember that this is an exact list of parts that I used, but I gradually cobbled together the supplies for this project over a long period of time. I didn't sit down, compare vendors (e.g. Adafruit vs. Sparkfun) and find the absolute cheapest way to build this. So, feel free to shop around to bring down the cost (and post links in the comments if you find a better/cheaper version of a certain part). Quantities are just 1 (one) unless otherwise noted, prices are rounded to the nearest dollar as of September 2013.
Update Feb. 2016: A kit with all the electronic materials for this project is now available from Jameco Electronics. Please note that this kit does not include materials for building the mirror frame so you will still need to purchase those separately (see below). I earn a commission on sales of this kit as described at the bottom of this page.
Important: there are three main parts that need to fit together to build this: the regular mirror, the frame, and the one-way mirror. First, it's easiest if you can find a cardboard/paper-mache lid and a regular mirror that will fit snugly inside it - the parts I bought didn't fit together perfectly, so I had to use a workaround (see Step 6). Second, cutting acrylic can be a pain depending on the tools you have available, so plan accordingly (see Steps 9 and 10). There's also an important consideration regarding the LED strip, which can't be cut to any length - it has to be cut in multiples of 3-LED segments, which are just shy of 2" long - so you want the inside perimeter of your mirror frame to be a multiple of that length. So, I'll link to the parts I used to build my mirror, but you can still follow these directions to build a mirror of a different size or shape.
Got all that? Time to start building!
Ok, almost time to start building. First, I want to preemptively address another common comment: how do these things actually work? Not surprisingly, there is no magic involved. The secret is that the infinity mirror actually contains two mirrors with different transmissivity and reflectivity. For all practical intents and purposes, mirrors that we deal with in everyday life are 100% reflective (technically a tiny amount of light will also be absorbed, but we can ignore that for now). That's the regular mirror at the "back" of the infinity mirror (on the left in the diagram above). The tinted window film, however (on the right in the diagram above), only reflects about half of the light that hits it*. This means that, when you sandwich an LED between the two mirrors, some of the light escapes through the front mirror and into your eye. The rest is bounced back off the rear mirror, then into the front mirror again, and this process continues off to infinity - thus the name. But, since a little bit of light escapes each time, each successive illusionary LED that you see will look a little bit dimmer, until they gradually disappear - you can't actually see infinitely many LEDs.
Note that this does not work because the window tint "only lets light through in one direction", which is a common misconception. In order for the illusion to work properly, the side of the front mirror the observer is on (the outside world) must be much darker than the side with the LEDs (inside the infinity mirror). This is the same effect that you see in crime dramas/movies where someone is held in an interrogation room that has a mirror on the wall, but there are people on the other side of that mirror observing as though it's just a window. That only works if the interrogation room is well-lit and the observation room is dark. *The exact percentages of reflectivity/transmissivity might vary depending on what kind you buy - different levels of reflectivity and transmissivity are actually regulated in different states for use in car windows, Google it if you're curious.
It's probably a good idea to build, test, and debug your circuit before you build the mirror. Otherwise, it would be quite sad if you get a nice, fancy mirror built only to throw the switch and find out something doesn't work. So, first let's assemble the circuit and test the LED strip.
If you're new to circuits and don't understand what's going on, you can either: (a) just blindly follow the directions, or (b) look ahead to the next step for an explanation of how the circuit works. If you have experience working with breadboards, you can go ahead and assemble the circuit based on the third breadboard diagram above, or directly from the circuit diagram. For newbies I broke it into three steps, hopefully to make things less overwhelming - corresponding to the first three diagrams above:
1) Populate the breadboard with the three MOSFETs, four potentiometers, SPDT switch, and barrel jack adapter. I made these parts "transparent" in the figure above so you can see exactly where their pins go*.
2) Add wires to connect to your power and ground rails. I've color-coded these with red and black here, but remember that you can use whatever colors you want if you just have a multi-colored jumper wire kit and no red and black hookup wire. Notice how one of the breadboard rails is connected to the +12V supply from the barrel jack (which feeds power to the Arduino through Vin), and one is connected to the Arduino's +5V power pin, but they share a common ground. Whatever else you do, don't short the +12V and +5V supplies together!
3) Add wires to connect to the Arduino's inputs and outputs, and wires that you will connect to your LED strip (if your strip came with pre-soldered wires, use those)**. Again, I've color-coded the respective red, green, and blue wires here but your ability to do that will depend on what wire you have available. *
I started making this diagram in Fritzing, but got frustrated with the enormous amount of space components like MOSFETs and potentiometers take up in breadboard view mode (they give a quasi-3D view instead of a "top-down" view, so take up way more space than they do in real life and obscure other things on the breadboard). So, I took a screenshot of the Arduino and breadboard and drew over them in Powerpoint.
If your LED strip did come with pre-soldered wires, be careful about the color coding. SparkFun's product page notes that the blue and green wires are switched, which can be irritating but won't cause any harm. My strip came with a black wire connected to V+, and getting the polarity reversed on the LED strip could be bad news. I guess I understand not wanting to use two red wires (one for V+ and one for the red LEDs) but I wish they'd use something other than black for V+.
This is a rough explanation of how the circuit works and what the components are for. Seasoned veterans can skip this step, but read on if you're curious. I don't have time to write a whole introductory chapter on circuits so I've tried to provide relevant links when possible.
Copy and paste the Arduino code below into a new sketch. I won't write my own tutorial here, so if you don't know how to create/upload a sketch, check out the official Arduino - Getting Started page. If you want to learn more about a specific command, just Google it (e.g. "Arduino analogWrite") and the official help page should pop right up. Caveat: this probably isn't the most efficient code! Particularly, I'm not sure of a nicer way to continuously monitor the fade-speed potentiometer without copying and pasting the same line of code over and over, or if there's a way to break out of a for loop if you flip the toggle switch (right now, if you switch to individual-control mode while in color-fade mode, the switch won't occur until it finishes the current fade cycle). So, I'll throw that out there as a challenge to anyone who's reading this and wants to post better code. Clearly I'm a mechanical engineer at heart and not a programmer.
// Arduino code to control and RGB LED strip // Uses a toggle switch to switch between color-fade mode // and individual RGB control mode // adapted from http://learn.adafruit.com/rgb-led-strips/example-code const int RED = 9; // define digital output pins for individual red, const int GREEN = 10; //green and blue channels const int BLUE = 11; const int POT1 = 0; // define analog input pins for three potentiometers const int POT2 = 1; const int POT3 = 2; const int POT4 = 3; const int BUTTON = 2; // define digital input pin for the switch int val = 0; // stores the state of the switch input pin int FADESPEED = 0; // initiate fade speed set by potentiometer int r = 0; // initialize the red, green and blue values int g = 0; int b = 0; void setup(){ pinMode(RED, OUTPUT); // define digital pins as outputs and inputs as needed pinMode(GREEN, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(BUTTON, INPUT); } void loop(){ val = digitalRead(BUTTON); // read the input value from the toggle switch if (val == HIGH){ // code for RGB color fade FADESPEED = analogRead(POT4)/10; // set the fade speed by reading analog input from 4th potentiometer // analogRead will output a number between 0 and 1023, and "delay" // is in milliseconds, so the biggest delay you'll get here is about // 1/10 of a second. Divide by a different number to change the max // fade time. // fade from blue to violet for (r = 0; r < 256; r++) { analogWrite(RED, r); FADESPEED = analogRead(POT4)/10; // check the fade speed continuously, otherwise // it won't update until it's gone through a complete cycle. // Probably not the most efficient way to do this... delay(FADESPEED); } // fade from violet to red for (b = 255; b > 0; b--) { analogWrite(BLUE, b); FADESPEED = analogRead(POT4)/10; } // fade from red to yellow for (g = 0; g < 256; g++) { analogWrite(GREEN, g); FADESPEED = analogRead(POT4)/10; delay(FADESPEED); } // fade from yellow to green for (r = 255; r > 0; r--) { analogWrite(RED, r); FADESPEED = analogRead(POT4)/10; delay(FADESPEED); } // fade from green to teal for (b = 0; b < 256; b++) { analogWrite(BLUE, b); FADESPEED = analogRead(POT4)/10; delay(FADESPEED); } // fade from teal to blue for (g = 255; g > 0; g--) { analogWrite(GREEN, g); FADESPEED = analogRead(POT4)/10; delay(FADESPEED); } } else { // code for individual RGB control with potentiometers r = analogRead(POT3)/4; // read values from the 3 potentiometers and divide by 4 to set brightness g = analogRead(POT2)/4; // note that analog read is 10-bit (0-1023), analog write is an 8-bit PWM b = analogRead(POT1)/4; // signal so you need to divide this value by 4. analogWrite(RED, r); // write analog values to red, green and blue output pins analogWrite(GREEN, g); analogWrite(BLUE, b); } }
Plug your power supply into the barrel jack adapter, and after your Arduino takes a second to boot up, you should be able to control the lights! Use the toggle switch to switch between two modes. In one mode, you can directly the control the red, green, and blue LED brightness with the first three potentiometers; and combine them to make different colors. In the other mode, the LEDs will fade between colors automatically, but you can control the speed of the fading with the fourth potentiometer. Watch this video for a demonstration, and see below for troubleshooting tips if it doesn't work. Notice how there are a couple spots in this video where my LEDs flicker - this must mean I have a loose connection or two bare wires bumping into each other somewhere when I jostle the Arduino around. Watch out for that.
You may have noticed a trend here - the general idea is to break your circuit (or code) down into smaller, isolated sections that can be tested individually. This lets you narrow things down and search for problems in a compartmentalized way, instead of just staring at a giant circuit and mess of code and wondering what went wrong. If you can think of other/better ways to debug this circuit, please chime in in the comments.
So, this is where I hoped that my 9" diameter mirror would fit snugly inside my 9" diameter lid, or the box itself. As you can see from the photos above, it didn't (they were just too small), and the 10" diameter box and lid were too big. My workaround was to cut out the top of the 9" lid and just use the rim. I kept the circular piece that I cut out of the top to reinforce the back of the mirror. So: 1) Use a utility knife to carefully cut out the top of your cardboard lid. Not necessary if you bought a lid/mirror combo that fit together snugly. 2) Paint both pieces a color of your choice. I believe the illusion will work better if the inside of the rim is black, the outside doesn't really matter. 3) Drill a hole in the side of the rim that's big enough for the wires from your LED strip to fit through. In hindsight, I probably should have drilled first and painted second.
Thread the LED strip wires through the hole you drilled in the cardboard lid. Carefully begin to remove the adhesive paper backing from the LED strip, and press it firmly against the inside perimeter or the lid. Make sure it is centered inside the rim. Once you've gotten the entire way around, cut the LED strip. Important: the LED can't just be cut anywhere - you have to cut it in 3-LED segments, and you can see the cut lines with labeled solder pads. If you cut anywhere else, the last few LEDs of your strip won't work. You'll also have to hope that the circumference of your lid matches up nicely with a multiple of the length of these 3-LED segments (about 1 15/16"), otherwise you could wind up with either a gap or a bit of overlap between your first and last LEDs.
The mirrors I bought came with small hooks on the back, and I accidentally ripped the hook off the 9" mirror when I was removing it from the packaging. So, it's probably a good thing I didn't try to use that to hang it on a wall. That works out anyway because you'll want to remove the hook so you can mount the mirror flat on the inside of your frame. I super-glued the back of the mirror to the flat (non-painted) part of the cardboard lid from earlier. Now is probably a good time to make sure your mirror is clean and free from fingerprint smudges, because any defects will detract from the illusion in the finished product. I used paper towels to handle/pick up the mirror from this point on, to avoid getting additional fingerprint marks around the edges. After gluing the mirror to the cardboard circle, I just used electrical tape to wrap around the outer edge of the rim with the LED strip and attach it to the mirror (of course duct tape would work too, but I wanted it to be black). Again, this is just a roundabout process that I had to go through because my mirror didn't fit inside the lid to begin with. Once you have everything secure, it's probably a good idea to fire up the Arduino and make sure you didn't somehow damage the LED strip or wires during this process.
So, in grad school I used a laser to cut acrylic all the time, and it worked great. Now I don't have a laser so that wasn't an option, and I really wanted to use the 9" mirror instead of going with 6" and buying a pre-cut 6" acrylic circle. That meant I had to cut my own acrylic. Thanks to everyone who pitched in to this forum thread with ideas.
IMPORTANT SAFETY INFORMATION BEFORE CONTINUING: If you're using a laser, acrylic fumes aren't good for you. If you're cutting/sawing/sanding/whatever-ing it, you don't want to inhale the dust either. Be sure to work in a properly ventilated area and wear an appropriate mask if necessary.
So, with the jigsaw: I traced the outline of the 9" mirror onto the acrylic's paper backing. Then I used two C-clamps to hold it onto the edge of a table, and just roughly cut off the corners to make an octagon. Then I went in for successively smaller cuts following the line. The end result wasn't too bad - some cracking around the edges, but no catastrophic breaks that ruined the circular shape.
Some safety notes - first I tried this with a wood blade, which didn't work at all and resulted in some large, jagged pieces of acrylic snapping off when the blade snagged. Got a finer-toothed metal blade at the hardware store and that worked much better. The edges were still quite sharp so I just hand-sanded them to avoid cuts. As usual with power tools, I'd recommend safety glasses for this step.
My other approach to cutting the acrylic was scoring a circular outline with a utility knife, then scoring a bunch of additional radial lines, hoping I'd be able to break off individual pieces, and wind up with a circle left in the middle. The first time I tried this, I used C-clamps to clamp the acrylic down on the edge of a table, and then hit the breakaway pieces with a mallet. That didn't work and resulted in big chunks breaking off inside the circular perimeter (this works fine for straight cuts if you're making a rectangular mirror, though). Next, I took some helpful advice from the forum thread: I scored the acrylic and then put it in the freezer for a few hours. Then I used the C-clamps again, but snapped the edges off with a vise grip instead of hitting it with a mallet. This worked pretty well, with less cracking around the edges than the jigsaw method. It still had some sharp points sticking out, which I sanded down. To be fair, I never tried using the vise grips without freezing first, or using the mallet after freezing - so I can't say with 100% certainty whether it was the vise grips or the freezing that made it work better the second time.
At this point we'll assume you've somehow managed to cut your acrylic to the appropriate size. Make sure you wipe down/clean off your acrylic (fingerprint smudges, dust from sanding etc) before you continue. Next you'll need to cut a piece of mirror tint that is bigger than your piece of acrylic - this means you can handle the extra material on the edges without worrying about fingerprint smudges. The window tint comes with a clear protective coating on one side, that you need to remove to expose the sticky adhesive. Start in a corner and carefully use your fingernail to peel up the clear layer (this can be a pain to do), then carefully lay the mirror tint flat on your piece of acrylic. I think this is the most frustrating/difficult part of the whole project - you want to get the tint as flat as possible, without any air bubbles. Big air bubbles will be painfully visible in the final mirror and can detract from the illusion. I did my best to get the tint as flat as possible, and "popped" a few air bubbles by pushing them toward the outer edge with my fingertip (using a paper towel so I didn't smudge the window tint). If you really mess up on your first try, you can peel the window tint off most of the way and try laying it down flat again, the adhesive shouldn't lose its stickiness. If all else fails you can also just cut a new piece. Once you're happy with the appearance and smoothness of your window tint, use scissors to cut around the outer perimeter so it's flush with your piece of acrylic.
Nothing fancy here...place the one-way mirror with the mirror tint facing in*. I just used electrical tape around the outer edge again. If you wanted to get fancier, you could mount the one-way mirror on the inside of a slightly larger cardboard lid and then fit that around the outside of your frame. *Here I'm just following the directions I've seen on other infinity mirrors. Optically, it should work in either direction, as discussed in Step 1. Maybe the acrylic is just harder to scratch/easier to clean, so it's better to have that facing out...honestly I'm not sure.
Plug in the power supply and fire it up! Assuming you tested your LED strip in Step 5 and didn't have any major issues with constructing the mirror, it should work as advertised. Above are a bunch of photos I took in different lighting conditions (the darker the room, the better the "infinity" effect), and below is a video of the final product in action. I want to make this tutorial as clear as possible for beginners - so if you saw something that wasn't clear, or I skipped over/implied something that you think should be spelled out, please leave a comment to let me know. Thanks for reading! Here's a video of the final product:
![]() |
| × | 1 | |||
| × | 1 | ||||
| × | 4 | ||||
| × | 3 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 |
Update 11/22/2013: Thanks to everyone who voted for this project in the Microcontroller Contest! It was one of three first-prize winners.
Update 9/17/2013: Thanks to everyone who voted for this project in the Arduino contest (I was one of ten "second prize" winners)! If you want to try this project with an addressable LED strip instead of an analog strip, check out the Rainbow Jar project (also an Arduino contest winner).
This is my take on a combination of two classic projects: RGB LED control with an Arduino, and an Infinity Mirror. It's an RGB LED infinity mirror that lets you toggle between an adjustable-speed color-fade mode and a direct-control mode where you individually set the red, green, and blue LED brightness levels.
The primary inspiration for this particular project comes from this infinity mirror Instructable and Adafruit's RGB LED Strip tutorial, but there are many more quality resources out there on both projects.
I've done my best to gear this project towards newbies by providing an exact list of materials I used and the exact procedure that I followed. One recurring theme I've noticed in comment sections for other infinity mirrors is a lack of links to specific parts (e.g. exactly what type of LEDs or LED strips were used, what power supply, where to buy the mirrors, the enclosure, etc). Clearly, if you know what you're doing and want to spend more (or less) money to design a slightly different mirror, you can adjust your materials as needed, use a different Arduino board, etc. You can skip the Arduino entirely and make a pretty simple, cheap infinity mirror if you want (just search Instructables for "infinity mirror" and you'll find a few), or go crazy and spend hundreds if not thousands of dollars (search YouTube for "infinity mirror table" and you'll get the idea).
On to the materials list. Remember that this is an exact list of parts that I used, but I gradually cobbled together the supplies for this project over a long period of time. I didn't sit down, compare vendors (e.g. Adafruit vs. Sparkfun) and find the absolute cheapest way to build this. So, feel free to shop around to bring down the cost (and post links in the comments if you find a better/cheaper version of a certain part). Quantities are just 1 (one) unless otherwise noted, prices are rounded to the nearest dollar as of September 2013.
Update Feb. 2016: A kit with all the electronic materials for this project is now available from Jameco Electronics. Please note that this kit does not include materials for building the mirror frame so you will still need to purchase those separately (see below). I earn a commission on sales of this kit as described at the bottom of this page.
Important: there are three main parts that need to fit together to build this: the regular mirror, the frame, and the one-way mirror. First, it's easiest if you can find a cardboard/paper-mache lid and a regular mirror that will fit snugly inside it - the parts I bought didn't fit together perfectly, so I had to use a workaround (see Step 6). Second, cutting acrylic can be a pain depending on the tools you have available, so plan accordingly (see Steps 9 and 10). There's also an important consideration regarding the LED strip, which can't be cut to any length - it has to be cut in multiples of 3-LED segments, which are just shy of 2" long - so you want the inside perimeter of your mirror frame to be a multiple of that length. So, I'll link to the parts I used to build my mirror, but you can still follow these directions to build a mirror of a different size or shape.
Got all that? Time to start building!
Ok, almost time to start building. First, I want to preemptively address another common comment: how do these things actually work? Not surprisingly, there is no magic involved. The secret is that the infinity mirror actually contains two mirrors with different transmissivity and reflectivity. For all practical intents and purposes, mirrors that we deal with in everyday life are 100% reflective (technically a tiny amount of light will also be absorbed, but we can ignore that for now). That's the regular mirror at the "back" of the infinity mirror (on the left in the diagram above). The tinted window film, however (on the right in the diagram above), only reflects about half of the light that hits it*. This means that, when you sandwich an LED between the two mirrors, some of the light escapes through the front mirror and into your eye. The rest is bounced back off the rear mirror, then into the front mirror again, and this process continues off to infinity - thus the name. But, since a little bit of light escapes each time, each successive illusionary LED that you see will look a little bit dimmer, until they gradually disappear - you can't actually see infinitely many LEDs.
Note that this does not work because the window tint "only lets light through in one direction", which is a common misconception. In order for the illusion to work properly, the side of the front mirror the observer is on (the outside world) must be much darker than the side with the LEDs (inside the infinity mirror). This is the same effect that you see in crime dramas/movies where someone is held in an interrogation room that has a mirror on the wall, but there are people on the other side of that mirror observing as though it's just a window. That only works if the interrogation room is well-lit and the observation room is dark. *The exact percentages of reflectivity/transmissivity might vary depending on what kind you buy - different levels of reflectivity and transmissivity are actually regulated in different states for use in car windows, Google it if you're curious.
It's probably a good idea to build, test, and debug your circuit before you build the mirror. Otherwise, it would be quite sad if you get a nice, fancy mirror built only to throw the switch and find out something doesn't work. So, first let's assemble the circuit and test the LED strip.
If you're new to circuits and don't understand what's going on, you can either: (a) just blindly follow the directions, or (b) look ahead to the next step for an explanation of how the circuit works. If you have experience working with breadboards, you can go ahead and assemble the circuit based on the third breadboard diagram above, or directly from the circuit diagram. For newbies I broke it into three steps, hopefully to make things less overwhelming - corresponding to the first three diagrams above:
1) Populate the breadboard with the three MOSFETs, four potentiometers, SPDT switch, and barrel jack adapter. I made these parts "transparent" in the figure above so you can see exactly where their pins go*.
2) Add wires to connect to your power and ground rails. I've color-coded these with red and black here, but remember that you can use whatever colors you want if you just have a multi-colored jumper wire kit and no red and black hookup wire. Notice how one of the breadboard rails is connected to the +12V supply from the barrel jack (which feeds power to the Arduino through Vin), and one is connected to the Arduino's +5V power pin, but they share a common ground. Whatever else you do, don't short the +12V and +5V supplies together!
3) Add wires to connect to the Arduino's inputs and outputs, and wires that you will connect to your LED strip (if your strip came with pre-soldered wires, use those)**. Again, I've color-coded the respective red, green, and blue wires here but your ability to do that will depend on what wire you have available. *
I started making this diagram in Fritzing, but got frustrated with the enormous amount of space components like MOSFETs and potentiometers take up in breadboard view mode (they give a quasi-3D view instead of a "top-down" view, so take up way more space than they do in real life and obscure other things on the breadboard). So, I took a screenshot of the Arduino and breadboard and drew over them in Powerpoint.
If your LED strip did come with pre-soldered wires, be careful about the color coding. SparkFun's product page notes that the blue and green wires are switched, which can be irritating but won't cause any harm. My strip came with a black wire connected to V+, and getting the polarity reversed on the LED strip could be bad news. I guess I understand not wanting to use two red wires (one for V+ and one for the red LEDs) but I wish they'd use something other than black for V+.
This is a rough explanation of how the circuit works and what the components are for. Seasoned veterans can skip this step, but read on if you're curious. I don't have time to write a whole introductory chapter on circuits so I've tried to provide relevant links when possible.
Copy and paste the Arduino code below into a new sketch. I won't write my own tutorial here, so if you don't know how to create/upload a sketch, check out the official Arduino - Getting Started page. If you want to learn more about a specific command, just Google it (e.g. "Arduino analogWrite") and the official help page should pop right up. Caveat: this probably isn't the most efficient code! Particularly, I'm not sure of a nicer way to continuously monitor the fade-speed potentiometer without copying and pasting the same line of code over and over, or if there's a way to break out of a for loop if you flip the toggle switch (right now, if you switch to individual-control mode while in color-fade mode, the switch won't occur until it finishes the current fade cycle). So, I'll throw that out there as a challenge to anyone who's reading this and wants to post better code. Clearly I'm a mechanical engineer at heart and not a programmer.
// Arduino code to control and RGB LED strip
// Uses a toggle switch to switch between color-fade mode
// and individual RGB control mode
// adapted from http://learn.adafruit.com/rgb-led-strips/example-code
const int RED = 9; // define digital output pins for individual red,
const int GREEN = 10; //green and blue channels
const int BLUE = 11;
const int POT1 = 0; // define analog input pins for three potentiometers
const int POT2 = 1;
const int POT3 = 2;
const int POT4 = 3;
const int BUTTON = 2; // define digital input pin for the switch
int val = 0; // stores the state of the switch input pin
int FADESPEED = 0; // initiate fade speed set by potentiometer
int r = 0; // initialize the red, green and blue values
int g = 0;
int b = 0;
void setup(){
pinMode(RED, OUTPUT); // define digital pins as outputs and inputs as needed
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(BUTTON, INPUT);
}
void loop(){
val = digitalRead(BUTTON); // read the input value from the toggle switch
if (val == HIGH){ // code for RGB color fade
FADESPEED = analogRead(POT4)/10;
// set the fade speed by reading analog input from 4th potentiometer
// analogRead will output a number between 0 and 1023, and "delay"
// is in milliseconds, so the biggest delay you'll get here is about
// 1/10 of a second. Divide by a different number to change the max
// fade time.
// fade from blue to violet
for (r = 0; r < 256; r++) {
analogWrite(RED, r);
FADESPEED = analogRead(POT4)/10;
// check the fade speed continuously, otherwise
// it won't update until it's gone through a complete cycle.
// Probably not the most efficient way to do this...
delay(FADESPEED);
}
// fade from violet to red
for (b = 255; b > 0; b--) {
analogWrite(BLUE, b);
FADESPEED = analogRead(POT4)/10;
}
// fade from red to yellow
for (g = 0; g < 256; g++) {
analogWrite(GREEN, g);
FADESPEED = analogRead(POT4)/10;
delay(FADESPEED);
}
// fade from yellow to green
for (r = 255; r > 0; r--) {
analogWrite(RED, r);
FADESPEED = analogRead(POT4)/10;
delay(FADESPEED);
}
// fade from green to teal
for (b = 0; b < 256; b++) {
analogWrite(BLUE, b);
FADESPEED = analogRead(POT4)/10;
delay(FADESPEED);
}
// fade from teal to blue
for (g = 255; g > 0; g--) {
analogWrite(GREEN, g);
FADESPEED = analogRead(POT4)/10;
delay(FADESPEED);
}
}
else { // code for individual RGB control with potentiometers
r = analogRead(POT3)/4;
// read values from the 3 potentiometers and divide by 4 to set brightness
g = analogRead(POT2)/4; // note that analog read is 10-bit (0-1023), analog write is an 8-bit PWM
b = analogRead(POT1)/4; // signal so you need to divide this value by 4.
analogWrite(RED, r); // write analog values to red, green and blue output pins
analogWrite(GREEN, g);
analogWrite(BLUE, b);
}
}
Plug your power supply into the barrel jack adapter, and after your Arduino takes a second to boot up, you should be able to control the lights! Use the toggle switch to switch between two modes. In one mode, you can directly the control the red, green, and blue LED brightness with the first three potentiometers; and combine them to make different colors. In the other mode, the LEDs will fade between colors automatically, but you can control the speed of the fading with the fourth potentiometer. Watch this video for a demonstration, and see below for troubleshooting tips if it doesn't work. Notice how there are a couple spots in this video where my LEDs flicker - this must mean I have a loose connection or two bare wires bumping into each other somewhere when I jostle the Arduino around. Watch out for that.
You may have noticed a trend here - the general idea is to break your circuit (or code) down into smaller, isolated sections that can be tested individually. This lets you narrow things down and search for problems in a compartmentalized way, instead of just staring at a giant circuit and mess of code and wondering what went wrong. If you can think of other/better ways to debug this circuit, please chime in in the comments.
So, this is where I hoped that my 9" diameter mirror would fit snugly inside my 9" diameter lid, or the box itself. As you can see from the photos above, it didn't (they were just too small), and the 10" diameter box and lid were too big. My workaround was to cut out the top of the 9" lid and just use the rim. I kept the circular piece that I cut out of the top to reinforce the back of the mirror. So: 1) Use a utility knife to carefully cut out the top of your cardboard lid. Not necessary if you bought a lid/mirror combo that fit together snugly. 2) Paint both pieces a color of your choice. I believe the illusion will work better if the inside of the rim is black, the outside doesn't really matter. 3) Drill a hole in the side of the rim that's big enough for the wires from your LED strip to fit through. In hindsight, I probably should have drilled first and painted second.
Thread the LED strip wires through the hole you drilled in the cardboard lid. Carefully begin to remove the adhesive paper backing from the LED strip, and press it firmly against the inside perimeter or the lid. Make sure it is centered inside the rim. Once you've gotten the entire way around, cut the LED strip. Important: the LED can't just be cut anywhere - you have to cut it in 3-LED segments, and you can see the cut lines with labeled solder pads. If you cut anywhere else, the last few LEDs of your strip won't work. You'll also have to hope that the circumference of your lid matches up nicely with a multiple of the length of these 3-LED segments (about 1 15/16"), otherwise you could wind up with either a gap or a bit of overlap between your first and last LEDs.
The mirrors I bought came with small hooks on the back, and I accidentally ripped the hook off the 9" mirror when I was removing it from the packaging. So, it's probably a good thing I didn't try to use that to hang it on a wall. That works out anyway because you'll want to remove the hook so you can mount the mirror flat on the inside of your frame. I super-glued the back of the mirror to the flat (non-painted) part of the cardboard lid from earlier. Now is probably a good time to make sure your mirror is clean and free from fingerprint smudges, because any defects will detract from the illusion in the finished product. I used paper towels to handle/pick up the mirror from this point on, to avoid getting additional fingerprint marks around the edges. After gluing the mirror to the cardboard circle, I just used electrical tape to wrap around the outer edge of the rim with the LED strip and attach it to the mirror (of course duct tape would work too, but I wanted it to be black). Again, this is just a roundabout process that I had to go through because my mirror didn't fit inside the lid to begin with. Once you have everything secure, it's probably a good idea to fire up the Arduino and make sure you didn't somehow damage the LED strip or wires during this process.
So, in grad school I used a laser to cut acrylic all the time, and it worked great. Now I don't have a laser so that wasn't an option, and I really wanted to use the 9" mirror instead of going with 6" and buying a pre-cut 6" acrylic circle. That meant I had to cut my own acrylic. Thanks to everyone who pitched in to this forum thread with ideas.
IMPORTANT SAFETY INFORMATION BEFORE CONTINUING: If you're using a laser, acrylic fumes aren't good for you. If you're cutting/sawing/sanding/whatever-ing it, you don't want to inhale the dust either. Be sure to work in a properly ventilated area and wear an appropriate mask if necessary.
So, with the jigsaw: I traced the outline of the 9" mirror onto the acrylic's paper backing. Then I used two C-clamps to hold it onto the edge of a table, and just roughly cut off the corners to make an octagon. Then I went in for successively smaller cuts following the line. The end result wasn't too bad - some cracking around the edges, but no catastrophic breaks that ruined the circular shape.
Some safety notes - first I tried this with a wood blade, which didn't work at all and resulted in some large, jagged pieces of acrylic snapping off when the blade snagged. Got a finer-toothed metal blade at the hardware store and that worked much better. The edges were still quite sharp so I just hand-sanded them to avoid cuts. As usual with power tools, I'd recommend safety glasses for this step.
My other approach to cutting the acrylic was scoring a circular outline with a utility knife, then scoring a bunch of additional radial lines, hoping I'd be able to break off individual pieces, and wind up with a circle left in the middle. The first time I tried this, I used C-clamps to clamp the acrylic down on the edge of a table, and then hit the breakaway pieces with a mallet. That didn't work and resulted in big chunks breaking off inside the circular perimeter (this works fine for straight cuts if you're making a rectangular mirror, though). Next, I took some helpful advice from the forum thread: I scored the acrylic and then put it in the freezer for a few hours. Then I used the C-clamps again, but snapped the edges off with a vise grip instead of hitting it with a mallet. This worked pretty well, with less cracking around the edges than the jigsaw method. It still had some sharp points sticking out, which I sanded down. To be fair, I never tried using the vise grips without freezing first, or using the mallet after freezing - so I can't say with 100% certainty whether it was the vise grips or the freezing that made it work better the second time.
At this point we'll assume you've somehow managed to cut your acrylic to the appropriate size. Make sure you wipe down/clean off your acrylic (fingerprint smudges, dust from sanding etc) before you continue. Next you'll need to cut a piece of mirror tint that is bigger than your piece of acrylic - this means you can handle the extra material on the edges without worrying about fingerprint smudges. The window tint comes with a clear protective coating on one side, that you need to remove to expose the sticky adhesive. Start in a corner and carefully use your fingernail to peel up the clear layer (this can be a pain to do), then carefully lay the mirror tint flat on your piece of acrylic. I think this is the most frustrating/difficult part of the whole project - you want to get the tint as flat as possible, without any air bubbles. Big air bubbles will be painfully visible in the final mirror and can detract from the illusion. I did my best to get the tint as flat as possible, and "popped" a few air bubbles by pushing them toward the outer edge with my fingertip (using a paper towel so I didn't smudge the window tint). If you really mess up on your first try, you can peel the window tint off most of the way and try laying it down flat again, the adhesive shouldn't lose its stickiness. If all else fails you can also just cut a new piece. Once you're happy with the appearance and smoothness of your window tint, use scissors to cut around the outer perimeter so it's flush with your piece of acrylic.
Nothing fancy here...place the one-way mirror with the mirror tint facing in*. I just used electrical tape around the outer edge again. If you wanted to get fancier, you could mount the one-way mirror on the inside of a slightly larger cardboard lid and then fit that around the outside of your frame. *Here I'm just following the directions I've seen on other infinity mirrors. Optically, it should work in either direction, as discussed in Step 1. Maybe the acrylic is just harder to scratch/easier to clean, so it's better to have that facing out...honestly I'm not sure.
Plug in the power supply and fire it up! Assuming you tested your LED strip in Step 5 and didn't have any major issues with constructing the mirror, it should work as advertised. Above are a bunch of photos I took in different lighting conditions (the darker the room, the better the "infinity" effect), and below is a video of the final product in action. I want to make this tutorial as clear as possible for beginners - so if you saw something that wasn't clear, or I skipped over/implied something that you think should be spelled out, please leave a comment to let me know. Thanks for reading! Here's a video of the final product: