Build a
Motorised
Kaleidoscope
Spin mirrors with servo motors, light them up with colour-changing LEDs, and watch your Arduino paint infinite rainbow patterns! 🌈✨
🔬 The Science of Kaleidoscopes
A kaleidoscope creates its magical patterns through the physics of light reflection. Three mirrors are arranged in a triangle — every time light hits one mirror, it bounces into another, and that reflection bounces again, and again, creating a six-fold symmetrical pattern from just a few tiny coloured beads or shapes.
Adding a servo motor to rotate the mirror tube means the pattern keeps changing — and an RGB LED gives you infinite colour possibilities. It's where physics, art, and programming meet!
Light bounces off a mirror at exactly the same angle it arrives. Three angled mirrors create a triangle of infinite reflections.
With mirrors at exactly 60° to each other, every object inside gets reflected 6 times, creating the classic hexagonal mandala pattern.
One servo slowly rotates the object chamber, changing the pattern. A second servo tilts the tube to change the viewing angle.
Red + Green + Blue LEDs mix to make any colour. Arduino controls each channel with PWM to cycle through the full rainbow.
🛒 Parts Shopping List
Everything available on Amazon India or Robu.in. Total cost around ₹1,600:
⚡ Circuit Diagram
A clean, compact circuit — everything plugs into one Arduino Uno:
🔧 Step-by-Step Build Guide
Follow every step in order. The physical build and the code work together — build first, then code!
The heart of your kaleidoscope is three mirrors arranged in a perfect equilateral triangle:
- Cut three acrylic mirror strips: each 1 cm wide × 12 cm long
- Arrange them reflective-side inward into a triangular prism — tape the outside edges with black electrical tape
- The internal angle of each mirror must be exactly 60° for 6-fold symmetry
- Use a clear plastic endcap or thin acetate sheet at one end as the "object cell" window
- Fill the object cell with: coloured glass beads, glitter, small gems, or cut foil pieces
- Seal the cell end loosely — it needs to rotate but not spill
Build the outer body that holds everything together:
- Outer tube: Use a 15 cm cardboard tube (paint inside flat black — absorbs stray light)
- Slide the mirror triangle prism inside the tube snugly
- Servo 1 (rotation): Mount at the object-cell end of the tube. Attach the servo horn to a disc that spins the object cell
- Servo 2 (tilt): Mount on a small base bracket — the tube rests on its horn so it can tilt forward and back
- RGB LED: Insert at the object cell end, pointing in — this lights up the beads from behind
- Viewing eye: The open end of the tube is where you look
Open Arduino IDE → Sketch → Include Library → Manage Libraries:
Library Manager// Search and install: "Servo" // Already built into Arduino IDE — no install needed // That's the only library needed for this project! // analogWrite() for RGB LED is built-in too.
This is the complete Arduino sketch — servo sweeping, rainbow colour cycling, potentiometer speed control, and button-selectable colour modes:
kaleidoscope.ino#include <Servo.h> // ── Pin Definitions ──────────────────────────── #define SERVO_ROTATE_PIN 9 #define SERVO_TILT_PIN 10 #define LED_R 3 // PWM #define LED_G 5 // PWM #define LED_B 6 // PWM #define POT_PIN A0 // speed control #define BTN_PIN 2 // colour mode button Servo servoRotate; Servo servoTilt; // ── State variables ───────────────────────────── int colourMode = 0; // 0=rainbow 1=red 2=grn 3=blu 4=white int rotAngle = 90; int rotDir = 1; // sweep direction int tiltAngle = 80; int tiltDir = 1; int hue = 0; // 0-255 for rainbow bool lastBtn = HIGH; unsigned long lastBtnTime = 0; // ── Rainbow: HSV hue (0-255) → RGB ────────────── void hueToRGB(int h, int& r, int& g, int& b) { int sector = h / 43; int frac = (h % 43) * 6; int p = 0; int q = 255 - frac; int t = frac; switch (sector) { case 0: r=255; g=t; b=p; break; case 1: r=q; g=255; b=p; break; case 2: r=p; g=255; b=t; break; case 3: r=p; g=q; b=255; break; case 4: r=t; g=p; b=255; break; default: r=255; g=p; b=q; break; } } // ── Set LED colour ────────────────────────────── void setColour(int r, int g, int b) { analogWrite(LED_R, r); analogWrite(LED_G, g); analogWrite(LED_B, b); } // ── Handle button press (debounced) ──────────── void checkButton() { bool btn = digitalRead(BTN_PIN); if (btn == LOW && lastBtn == HIGH && millis() - lastBtnTime > 250) { colourMode = (colourMode + 1) % 5; lastBtnTime = millis(); Serial.print("Colour mode: "); Serial.println(colourMode); } lastBtn = btn; } // ── Setup ─────────────────────────────────────── void setup() { servoRotate.attach(SERVO_ROTATE_PIN); servoTilt.attach(SERVO_TILT_PIN); servoRotate.write(90); servoTilt.write(80); pinMode(LED_R, OUTPUT); pinMode(LED_G, OUTPUT); pinMode(LED_B, OUTPUT); pinMode(BTN_PIN, INPUT_PULLUP); Serial.begin(9600); Serial.println("Kaleidoscope starting! 🌈"); } // ── Main Loop ─────────────────────────────────── void loop() { checkButton(); // Read potentiometer → rotation speed (5–30ms per step) int potVal = analogRead(POT_PIN); int stepDelay = map(potVal, 0, 1023, 5, 30); // ── Servo 1: sweep the rotation continuously ── rotAngle += rotDir; if (rotAngle >= 160 || rotAngle <= 20) rotDir = -rotDir; servoRotate.write(rotAngle); // ── Servo 2: slow tilt oscillation ──────────── static unsigned long lastTilt = 0; if (millis() - lastTilt > 80) { tiltAngle += tiltDir; if (tiltAngle >= 110 || tiltAngle <= 60) tiltDir = -tiltDir; servoTilt.write(tiltAngle); lastTilt = millis(); } // ── LED colour based on selected mode ───────── int r, g, b; switch (colourMode) { case 0: // 🌈 Rainbow hueToRGB(hue, r, g, b); setColour(r, g, b); hue = (hue + 2) % 256; break; case 1: setColour(255, 0, 0 ); break; // 🔴 Red case 2: setColour(0, 255, 0 ); break; // 🟢 Green case 3: setColour(0, 0, 255); break; // 🔵 Blue case 4: setColour(255, 255, 255); break; // ⚪ White } delay(stepDelay); }
hueToRGB() function converts a single 0–255 hue value into RGB components. As hue increases from 0 to 255, the colour travels through red → yellow → green → cyan → blue → magenta → back to red. This is the classic rainbow cycle!
Put it all together and make it look beautiful:
- Mount the Arduino and breadboard on a flat base plate (cardboard, wood, or acrylic)
- The tilt servo sits on the base — the tube rests horizontally on its horn bracket
- The rotation servo sits at the end of the tube, spinning the object cell cap
- Route wires neatly along the tube with cable ties or tape
- The potentiometer and button can be mounted on a small control panel in front
- Decorate the tube with coloured tape, paint, or wrap it in prismatic foil paper
🛠️ Troubleshooting Guide
Patterns not magical enough? Here's how to fix the most common issues:
| 🔴 Problem | 🟡 Likely Cause | ✅ Fix |
|---|---|---|
| No pattern visible — just dark | LED facing wrong direction or missing | Confirm RGB LED points INTO the object cell from behind. Check GND is connected to LED cathode |
| Only one colour on LED | 330Ω resistors missing on some channels | Each of R, G, B pins needs its own 330Ω resistor. Missing resistors can short the channel |
| Pattern has no symmetry (just blobs) | Mirror angles not exactly 60° | Remake the mirror triangle more carefully — all three 60° angles. Use a protractor to check |
| Servo jerks instead of sweeps smoothly | Delay too short OR potentiometer reads 0 | Set potentiometer to mid-position. In code, ensure stepDelay minimum is at least 5ms |
| Button does nothing | INPUT_PULLUP not working / wiring reversed | Button must connect pin to GND (not 5V). Confirm one leg to Pin 2, other leg to GND |
| Servos jitter when LED is on | Power supply insufficient | Both servos + RGB LED from Arduino 5V can strain the supply. Reduce to one servo or use external 5V |
| Reflection looks dim | Stray light entering tube sides | Paint or tape the inside of the outer tube completely flat black — this makes reflections vivid |
🚀 Level Up Your Kaleidoscope!
Once your motorised kaleidoscope is working, try these stunning enhancements:
Add a microphone module — colours and speed respond to music playing nearby!
Add HC-05 module — choose colours and speed from a phone app over Bluetooth!
Fix a phone camera at the eyepiece and record the patterns — instant mesmerising videos!
Replace beads with a real crystal or prism inside — creates sharp spectral light patterns!
Replace the single RGB LED with a 12-pixel NeoPixel ring for much brighter, richer colour mixing!
Upgrade to a stepper motor for precise rotation speeds — program exact pattern cycles!
❓ Frequently Asked Questions
When two mirrors face each other at 60°, each reflects the other's reflection. At exactly 60°, you get exactly 6 copies of the original object arranged in a perfect hexagon — because 360° ÷ 60° = 6. At 45° you'd see 8 copies, at 90° you'd see 4. The 60° angle produces the classic hexagonal kaleidoscope pattern!
Yes! Regular mirror glass works beautifully — often better than acrylic because it's perfectly flat. However, glass is harder to cut safely. Ask an adult to score and snap it, or use a glass cutter. Wrap the edges with electrical tape so you don't cut your fingers.
It converts a single "hue" value (0–255) into three separate brightness values for Red, Green, and Blue. Imagine a colour wheel — as the hue number increases, you travel around the wheel: red → orange → yellow → green → cyan → blue → purple → back to red. By slowly increasing the hue in the loop, we create a smooth rainbow animation!
At slow speeds you can see individual object positions clearly reflected in geometric arrangements. At fast speeds the objects blur into smooth colour gradients and the reflections merge into flowing abstract patterns. Both are beautiful — experiment to find your favourite speed!
Excellent choice — it sits right at the intersection of physics (optics, reflection), engineering (servo control, circuit design), and art (colour mixing, pattern). For a truly impressive exhibit, prepare an experiment comparing patterns with 3 mirrors vs 4 mirrors vs 6 mirrors — and measure how the number of reflections changes with the mirror angle.
Yes — a sealed transparent tube filled with coloured water, baby oil, or glycerine with glitter creates an amazing "liquid" kaleidoscope effect. Make sure the cell is completely sealed before letting it rotate, or it will leak. Silicone glue around the cap edges works well!

Comments
Post a Comment