Lucas Ainsworth
Published © GPL3+

Kaleidoscope Infinity Mirror

Build a beautiful “infinity mirror” Illusion that you can control by changing this mirrors' orientation. Rotate for changing colors!

BeginnerFull instructions provided3 hours32,225

Things used in this project

Hardware components

Arduino 101
Arduino 101
×1
1m Adressable unsealed LEDs (60)
This Sparkfun version is conveniently wired for this project, but you can use Adafruit's NeoPixels or similar.
×1
Short section of solid-core wire or jumper pins
This is to make stranded wire Arduino pin-compatible.
×1
heat shrink tubing
Optional if you are feeling fancy.
×1
barrel jack female connector w/screw terminals
×1
barrel jack male connector w/screw terminals
×1
3x AA battery holder with switch
×1
Pololu Valtage Step-Up Regulator
This $4 regulator allows the whole project to be powered from one battery pack with 3 AA batteries. Alternatively, you can skip this part and use a 9v battery to power the Arduino 101. If you go that route, you'll still need the 3 AA pack to power the lights. https://learn.adafruit.com/adafruit-neopixel-uberguide/power
×1
AA Batteries
AA Batteries
×1
12” square “shadow box” picture frame
The depth and size of this frame is perfect!
×1
12" square mirror
This will fit in the back of the picture frame.
×1
11" photo easel
To display the finished product
×1
Mirrored privacy tinting
(optional – greatly improves the effect, but not 100% required)
×1
FoamCore
Standard 3/16" or 1/4" FoamCore. I used white but black might look nice too. You need enough to make one 12" x 12" piece, plus enough to piece together a strip 1m long, 05” wide.
×1

Software apps and online services

Arduino IDE
Arduino IDE
You need the Adafruit NeoPixel library for this project. https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-installation Also, if you're new to the Arduino 101, you'll need to install the Curie Core to access the positional sensors. https://www.arduino.cc/en/Guide/Arduino101

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
box cutter with fresh blade
Hot glue gun (generic)
Hot glue gun (generic)
wire strippers

Story

Read more

Code

Arduino 101 Infinity Mirror Sketch

Arduino
Simple sketch that reads the angle of the Arduino 101 from the internal accelerometer, and uses the angle to control colors of a NeoPixel LED strip.
/*
   Copyright (c) 2016 Intel Corporation.  All rights reserved.
   See license notice at end of file.

  Arduino 101 "Infinity Mirror." The rotation angle of the Arduino 101 changes the lights in a Neopixel strip.
  This code uses the Adafruit Neopixel library. Library installation instructions here: https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-installation
  If using the desktop version of the Arduino IDE, make sure you have the latest Intel Curie Core installed. For more info, visit https://www.arduino.cc/en/Guide/Arduino101
*/



#include "CurieIMU.h"
#include <Adafruit_NeoPixel.h>
#define PIN 6  //// what pin are the NeoPixels connected to?
Adafruit_NeoPixel strip = Adafruit_NeoPixel(54, PIN, NEO_GRB + NEO_KHZ800);  /// the strip is 15 pixels long.  You can change this for the number of pixels in your individual strip.

int tr = 0;  //Some variables to hold "color-target" and "color-current" for smoothing...
int tg = 0;
int tb = 0;
int r = 0;
int g = 0;
int b = 0;

int rawX = 0;  /////  to hold values from the Curie's accelerometer
int rawY = 0;
//int rawZ = 0;
float angle = 0.0;


void setup() {
  // put your setup code here, to run once:

  //Serial.begin(9600);  //for debug.
  CurieIMU.begin();
  CurieIMU.setAccelerometerRange(2);  // Set the acceleromiter range to 2g.

  strip.begin();  //  intialize neopixel strip
  strip.show();   // Initialize all pixels to 'off'
}

void loop() {
  // put your main code here, to run repeatedly:

  // read accelerometer:
  int rawX = CurieIMU.readAccelerometer(X_AXIS);
  int rawY = CurieIMU.readAccelerometer(Y_AXIS);
  int rawZ = CurieIMU.readAccelerometer(Z_AXIS);


  angle = atan2(rawX, rawY); // the funtion atan2() converts x and y forces into an angle in radians.  cool!  Output is -3.14 to 3.14

  if (abs(angle) > 2.5) { //  digital pins are down
    ///  turn lights off in this position
    tr = 0;
    tg = 0;
    tb = 0;
    runlights();
  }

  if ((angle > 1.5) && (angle < 2.5)) {
    //make lights white in this position (equal r, g and b.)  Color values can go up to 255, but I find it's bright enough at 100.
    tr = 100;
    tg = 100;
    tb = 100;
    runlights();
  }
  
  else if ((angle < 1.5) && (angle > 0.5)) {
    //make lights red in this position
    tr = 100;
    tg = 0;
    tb = 0;
    runlights();
  }
  
  else if ((angle < 0.5) && (angle > -0.5)) {
    //make lights green in this position
    tr = 0;
    tg = 100;
    tb = 0;
    runlights();
  }
  

  else if ((angle < -1.5) && (angle > -2.5)) {
    //make lights blue in this position
    tr = 0;
    tg = 0;
    tb = 100;
    runlights();
  }

    else if ((angle < -0.5) && (angle > -1.5)) { ////  picking one corner angle for something fun!

theaterChase();  /// these functions are written out at the bottom of the sketch.  
//rainbowCycle(2);

  }
  
  else {
    ////  in case of some unexpected angle, turn lights off.
    tr = 0;
    tg = 0;
    tb = 0;
    runlights();
  }
}

void runlights() {
  /// color smoothing.  Current color moves toward target color...  If target is more than curent, move up, if less, move down.
  if (tr > r + 1) {
    r++;
  }
  if (tg > g + 1) {
    g++;
  }
  if (tb > b + 1) {
    b++;
  }
  if (tr < r) {
    r--;
  }
  if (tg < g) {
    g--;
  }
  if (tb < b) {
    b--;
  }

  //turn all the LEDS to the current r, g, b values.
  for (int i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, r, g, b);
  }
  strip.show();
  delay(10); //  time delay for simple fade timing.
}

///////////////Special light functions from Adafruit Strandtest Example Code

// Rainbow!  Note- this function blocks new position inputs until it's finished.
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

    //////Theater Chase lights from Adafruit strandtest example code.  This takes whatever the curent RGB value is, and does a "theatre chase" effect with it.
  void theaterChase(){  for (int j = 0; j < 3; j++) { //3cycles of chasing
      for (int q = 0; q < 3; q++) {
        for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) {
          strip.setPixelColor(i + q, r, g, b); //turn every third pixel on
        }
        strip.show();

        delay(50);

        for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) {
          strip.setPixelColor(i + q, 0);      //turn every third pixel off
        }
      }
    }
  }

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



////////////////////////////////////////////////////////////////////////////////////////////
/*
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

Credits

Lucas Ainsworth

Lucas Ainsworth

2 projects • 41 followers
I'm a designer working in the Modular Innovation Group at Intel.

Comments