Infinity Mirror With Ultra Sonic Sensors

16,485

113

6

Published

Introduction: Infinity Mirror With Ultra Sonic Sensors

About: Hack Sioux Falls Project!

This was my project for Hack Sioux Falls. I built it one weekend and it turned out a lot different than I thought it would. It was a lot of fun and there are a lot of variations on what you could have the Arduino code do once you get the shadowbox wired up.

My original idea was to use the ultrasonic sensors to sense movement in front of the mirror and then move an orange light around the box. By mounting the ultrasonic sensors towards the back of the shadowbox, they were less accurate than I hoped.

The final version did work just fine but when set on its stand, the bottom sensor gets false triggers. This would be easily fixed by moving the sensor or just hanging the shadowbox on the wall.

Another interesting effect that occurred was with the back of my shadow box. The way the hook connects to the frame, it causes the back to be on a small angle. So instead of looking straight into the mirror, it is on a slight angle and causes the infinity effect to look down instead.

The entire build took a few hours and was a lot of fun to create. Let's get started.

Step 1: Parts Needed

For this project, I purchased an old shadow box from a second-hand store. Since it was in good shape and already had a piece of glass installed, I didn't need to do any further work. Any shadow box or deep frame would work, it just needs to be large enough to hold the LED strip inside and have room for a front glass and back mirror.

Other parts you will need include

You will also need a few supplies.

  • Soldering iron (it is possible to use just crimpers)
  • Hot glue gun
  • Glass cutter (if your mirror or glass need to be cut)
  • Hookup wire, I used a piece of old networking cable (CAT5)
  • Dupont crimper (optional, but very useful)
  • 3D Printer (mine is a Robo3D)

My suggestion would be to improvise based on what supplies you have. These are the supplies I used.

Step 2: Adding a Film to the Glass

The very first step I did was add a mirrored film to my front glass. This turned out to be extremely easy to do.

The way the infinity mirror works with a back mirror and a "2-way" mirror on the front glass. The light will then bounce around between the back mirror and the 2-way mirror, eventually escaping the 2-way mirror. Leaving an effect that the mirror is infinitely deep.

I used a silver window shade film that left a very mirrored finish after applied. You might try different film shades for other effects as well.

Simply follow the instructions that come with your film and apply it the back of the front glass. For my film, you apply soapy water to the glass, cut the film to the exact size (or slightly smaller), apply and use a squeegee to push out the excess water. Let it dry overnight and you're all set.

Step 3: Installing the LED Strip

Measure your inside dimensions of the shadowbox and determine how many LEDs should be on each of the four sides. It will work best if there is an odd-number of LEDs on each side. Having an odd-number will allow one LED to be the center of your light.

Once you determine how many LEDs are needed for each side, carefully cut the LED strip, ensuring that you only cut at the designated locations and that you maintain the correct polarity of the final cut parts.

After cutting the LEDs, dry-fit them into the shadowbox and carefully measure how much connecting wire will be needed to re-join them in the corners. It is possible that you can avoid cutting some of the corners, it all depends on the size of your shadowbox. For mine, I only needed to cut one of the corners.

Solder the cut LED strips with short pieces of wire and apply heat-shrink tubing if you use bare wire. Make sure you are maintaining the correct polarity of the LEDs by aligning the arrows.

At the start of your LED strip, solder wire leads to hook up to your Arduino. These leads will be fished through the back mirror.

After your LEDs are properly cut and soldered, install them on the inside of your shadowbox by removing the back adhesive and sticking them to the frame. Do not trust that the adhesive will hold so apply hot-glue in key places throughout the LED strip. Taking special care in the corners since they will come loose there first.

Step 4: Building Backets for the Ultrasonic Sensors

There are many ways to attach the ultrasonic sensors to this project. I attached mine by soldering wire leads to 4 pins of a female header and then hot-glued the header to the backside of the frame. This allowed me to plug in my ultrasonic sensors and remove them if necessary.

Use 4 different colored wires on each of the headers and keep the order exactly the same as you go around the shadowbox. We will later be connecting all of the +5V and GND wires together and each ECHO, TRIGG wire will get connected to the Ardiuno. Keeping the colors consistent will make that process a lot easier.

After soldering the wires to the header, I added a small piece of shrink tubing to each.

Alternatively, the ultrasonic sensors could be soldered directly to the wires and mounted on the shadowbox.

Step 5: Installing the Mirror and Back

After the ultrasonic sensor headers are glued, it's time to glue our mirror to the shadowbox backer and install the back. If your mirror is too large, use a glass cutter to cut it to the correct size. Note that the correct size MAY be a 1/2 an inch smaller all the way around your backer.

My shadowbox uses a grove in the frame to hold the back and then two small metal hooks to hold it in place, giving my backer a slight angle. Your design may be different.

Using hot-glue, apply a few large blobs of glue to the back and press the mirror into position. Once the mirror is glued, fish the back around the wires and attached it to the frame. If necessary, apply a small amount of hot-glue in each corner.

Before installing the back, it might be a good idea to test your LED strip to make sure all of your wiring is correct. Also, make sure that the LED wire leads are pulled out of the back before attaching because we'll need those in the next step.

Step 6: Wiring Up the Arduino Uno and Ultra Sonic Sensors

Collect all of the GND wires from the ultrasonic sensors and add pigtail wire to the bundle before soldering them all together. This will be our common ground for all of the sensors. The pigtail wire will get plugged into the Arduino UNO.

Repeat that process for the +5V wires from all of the ultrasonic sensors as well. You should have bundles of wires all soldered together with ONE lead that will plug into the Arduino.

Next, the LED strip's GND and +5V should get a 100-200uF capacitor across its power. Make sure you observe the correct polarity, the negative of the capacitor goes on the GND wire. I soldered mine together using the same technique as the sensor's common wires.

Finally, on the LED strip's DATA wire, add a 200-500 ohm resistor in series. This will make sure our LED strip doesn't get an inrush of current causing our first LED to burn out.

Add heat-shrink tubing to ALL connections. The next step shows a circuit diagram if that is helpful.

Once all of the wiring is done, connect each wire up to the Arduino. GND to GND, +5V to +5V, LED Data to PIN 10 and the sensors to PINs 2-9.

I used my crimper to add Dupont ends to each wire. If you do NOT have a crimper, you can solder hook-up wires to each wire or solder them into header pins.

Step 7: Circuit Diagram

This is the circuit diagram for my design. It may look complicated at first glance but it is just 4 sensors, each with 4 wires, and the LED strip.

Step 8: Arduino Code

I chose to make an orange center dot with a pulsing LEDs around the sensor that measures the closest object. Of course, you could do something completely different now that you have the sensors and the base code.

Note:

  • This uses the Adafruit NeoPixel library, make sure you properly install that library.
  • The exact order of the sensors and their PIN numbers.
  • Adjust the total number of pixels that your shadowbox uses.
  • Adjust the colors as desired.
  • Tell the code where your "corners" are, these are the center points of each side of the box.
#include <Adafruit_NeoPixel.h>
const int NUMPIXELS = 26;

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, 10);

const int NUMPIXELS = 26;
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, 10);

const int topTrigPin = 2; const int topEchoPin = 3; const int leftTrigPin = 4; const int leftEchoPin = 5; const int botTrigPin = 6; const int botEchoPin = 7; const int rightTrigPin = 8; const int rightEchoPin = 9; void setup() { Serial.begin(9600); pixels.begin(); }

int corners[4] = {16, 23, 3, 10};

int focusPoint = 20; int focusMoveTo = 20; int rainbow = 0; uint32_t rainbowColor = Wheel(0);

unsigned long previousMillis = 0;

void loop() { unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= 500) { previousMillis = currentMillis; long top = readSensor(topTrigPin, topEchoPin); long left = readSensor(leftTrigPin, leftEchoPin); long bot = readSensor(botTrigPin, botEchoPin); long right = readSensor(rightTrigPin, rightEchoPin); Serial.print("t:"); Serial.print(top); Serial.print("l:"); Serial.print(left); Serial.print("b:"); Serial.print(bot); Serial.print("r:"); Serial.println(right);

rainbowColor = (Wheel((rainbow) & 255)); rainbow = (rainbow + 1) % 255;

if (top < left && top < bot && top < right ) { // move to top focusMoveTo = corners[0]; } else if (left < top && left < bot && left < right) { // move to left focusMoveTo = corners[1]; } else if (bot < top && bot < left && bot < right ) { // move to bot focusMoveTo = corners[2]; } else if ( right < top && right < left && right < bot ) { // move to right focusMoveTo = corners[3]; } } if (focusPoint != focusMoveTo) { if (focusPoint > focusMoveTo) { focusPoint--; } else { focusPoint++; } } bounceAround(focusPoint); delay(30); } int pos = 0; long readSensor(int trigPin, int echoPin) { pos++; if (pos == 5) { pos = 0; } return pos; pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);

long duration, cm; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); return microsecondsToCentimeters(duration); }

long microsecondsToCentimeters(long microseconds) { return microseconds/29/2; // to convert time into distance //The speed of sound is 340m/s or 29 microseconds per centimeter. //the ping travels out and back so distance from the obstacle is half of the distance travelled }

int bounceSize = 5; int bounceSizeMax = 5; int bounceDirection = 1;

void bounceAround(int point) { setAll(rainbowColor); if (bounceSize <= 0) { bounceDirection = 1; } if (bounceSize >= bounceSizeMax) { bounceDirection = -1; } bounceSize += bounceDirection; pixels.setPixelColor(point, pixels.Color(0,250,0)); for(int i = 1; i <= bounceSize; i++ ){ pixels.setPixelColor(point - i, pixels.Color(40*i,40*i,40*i)); pixels.setPixelColor(point + i, pixels.Color(40*i,40*i,40*i)); } showStrip(); }

void showStrip() { pixels.show(); }

void setAll(uint32_t color) { for(int i = 0; i < NUMPIXELS; i++ ) { pixels.setPixelColor(i, color); } }

void setAll(byte red, byte green, byte blue) { for(int i = 0; i < NUMPIXELS; i++ ) { pixels.setPixelColor(i, red, green, blue); } }

// Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0); }


Step 9: 3D Printing a Stand

With the Arduino and battery on the back, it won't fit snuggly on a wall so I decided to design and 3D Print a simple stand. After 4 revisions, this is the stand that I came up with. It has room for the bottom ultrasonic sensor and holds my shadow box tightly.

You may decide to do something different with your shadowbox.

Step 10: Summary

Glue your Arduino and battery pack to the back of the frame and you are done!

In the end, it turned out really well. There are many different ways to light the LEDs, this was my 4th version. I hope you enjoyed the project.

Share

    Recommendations

    • Clocks Contest

      Clocks Contest
    • Oil Contest

      Oil Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    6 Discussions

    Can you make the infinity mirror with just the frame, the 2-way mirror film, LED lights with a wire(s) leading out the bottom for power and a mirror for the back?

    1 more answer

    Sure. You could get a led strip with the remote control and power supply. You could use the remote to turn it on and off. Or you could just use a power supply and leave it on for a night light or mood lighting.

    Inifinity mirrors are always mesmerizing, yours is looking very clean and cool, but I think you have "too much for too little".
    Too much complex electronics for too little effect and interaction.

    Maybe you can implement something more interactive to compensate the complex electronics.

    That's neat, I'd love to see a video or pictures in a darker environment in order to see the full effect! Here the glare is kind of distracting