Introduction: Gesture Controlled Levitating Night Light
Lampinho (in Portuguese, "inho" is a suffix for "little") is a levitating night light that features brightness and color control using hand gestures. It is powered entirely by a common smartphone charger.
The project first started as a magnetic levitation experiment, it was when I thought "Hey, this would make a great night lamp!". Then, a single color prototype was built with the target illuminated from the top. It wasn't perfect, but proved to have potential.
Shorlty after, an improved version was made with the light source under the levitating object and a hidden RGB led to provide a multitude of colors. This is the one I'm sharing with you.
Step 1: Materials
In this project, levitation and lights are controlled by two different circuits that work independently.
For levitation, support structure and power you'll need:
- A circular or square piece of plastic, 14cm diameter or so. (This will be the base)
- A 12V electric lock solenoid coil (about 5 Ohms resistance)
- UF4007 fast diode (if you can't find this, try 1N4007 instead)
- Steel rod (if your coil comes with no metal core)
- BD135 (NPN transistor) and heatsink
- A1302 linear hall effect sensor
- 2k trimpot or potentiometer
- Clothespin to hold the coil
- A smartphone charger or 5V power supply
- A USB cable
- Male and female connectors for power (a standard power jack is preferred, but I used RCA connector)
- A small neodymium (Nd) magnet
- Some white translucent plastic for the target
Plastic bar and telescopic antenna from a FM radio, both at least 20cm long. This is for the main support of the coil, pretty much any metal or plastic rods will do.
For the lightning part:
- A small Arduino compatible board: Arduino Pro Mini or Nano should work fine. I used Digispark USB.
- Hollow tube with 7mm inner diameter to direct the led light. I used a marker pen
- A common-cathode 5mm RGB led
- HC-SR04 ultrasonic sensor
- 2x120Ohm resistor
- One 200Ohm resistor
Step 2: Main Structure and Coil
Let's begin to build Lampinho's skeleton by making a slightly angled cut of a 20cm piece of the plastic bar. Don't make it too angled, roughly 15º. Drill a hole 5mm from the border of the base (the mini drill from my other instructable was what I used for most holes in this project) and fix the angled bar there with a screw.
Then take the clothespin and make a hole on both sides like the picture shows. Also drill the end of the angled bar. Put a screw through these holes to hold it all together.
If you're up to a little Math exercise, we might get the location of the hole for the antenna by finding the plastic bar horizontal projection. Cosine will do this job for us: 20*cos(90º-15º)=5.18 cm. We will also have to add 5mm from the border + half of the plastic bar width (1cm in my case). All this gives us 6.18cm, and if you look at the picture, the hole is right there!
If you weren't in the mood, you might just have skipped that paragraph and drilled where you thought was best. Anyway, our support is now finished. Use some hot glue or rubber spacers to link the antenna to the clothespin.
In case your solenoid is coreless (aka air-core), insert a small rod of ferromagetic material to make the field stronger, keeping some extra length for the peg to hold.
Step 3: Levitation: Easier Than It Seems
When I first saw those toys that kept globes suspended in the air, I guessed they ran on magic or some kind of advanced alien technology! After learning more about them, though, I found out to my disappointment that neither was true. Well, some advanced methods exist that achieve extreme precision and stability, but the good news is that the same amazing results might be achieved using only a handful of parts.
Let's begin by the hall sensor:
- Solder some long wires or cables to its leads, long enough to reach the base. Using a single cable with extra wires for the coil may provide some more aesthetically pleasing results.
- Grab a 2mm thick piece of plastic roughly the size of the coil and glue it to the coil end. It's our spacer.
- Using a bit of hot glue or super glue, make sure the hall element stay in place, aligned to the center of the coil and with the active area facing down, the active area must not face the coil. Also make sure that your magnet (which we will soon use to built the target) doesn't stick to the hall or coil. If it does, use a thicker spacer.
- Cover everything with super glue, just like in the photo.
Next, build the circuit of the picture. It's pretty straightforward, but if you plan to keep it turned on for a long time, use a heat sink.
Step 4: Tuning
At this point, levitation circuitry is ready, except for the power cable. Grab some spare USB cable and cut the other end. It has 4 wires inside, of which only 2 concern us: black and red. Polarity here is pretty obvious, but it won't hurt to say that you should solder the black wire to the negative (probably also black) one of your male power connector, and the red to the positive.
Let's give Lampinho a purpose in life by making a small target for him to levitate. Use your piece of translucent plastic (or maybe glass) to create a cool shape and superglue a small neodymium magnet to its top. Keep the total mass of the target around 5g. Mine has a piece of steel inside the plastic cover as it was too light.
Now comes the tricky part, tuning. Power the device and hold the target close to the coil end, turning the potentiometer until it begins to levitate. Change the coil angle too if needed to achieve the best setting.
Adjust the system and the mass of the target until you are pleased with the result.
Step 5: A Bit of Light
The lightning circuit is the one that uses a microcontroller. Honestly, I didn't like working with the Digispark a lot because I had some detection and upload problems, but it has a conveniently small size, and in the end it worked fine.
Before the circuit, drill another hole exaclty under the coil, one that will keep the light delivery tube in place. No Math this time, just trust your eyes!
The schematic of the picture shows my whole circuit. Your levitation part should already be completed, so just add the led(with resistors), microcontroller and ultrasonic sensor. Fix these parts as you wish, keeping in mind we still have to program the MCU and the ultrasonic sensor transducers (the things that look like eyes) must be exposed and kept unblocked. Also, led should fit inside the tube.
Step 6: It's Alive!
This is the final step. Just upload the code and provide power.
Controlling Lampinho is very easy:
- Hold your hand close to the sensor for a second and the colors will start changing, take the hand away to select the current color.
- Hold your hand a bit farther from the sensor, wait for a blink and move it up or down to change the led brightness.
If you watched the intro video, you already know how it works. The detection distances in the code might be changed to provide the best interaction experience.
We are done now, just get comfy in your bed or chair and chill watching Lampinho move!