Create a bedside lamp with Arduino and NeoPixel strip
Bedside lamp in Monstropolis
Inspired by Monsters, Inc
The closet door opens itself. Sulley comes out, slowly. The tall blue monster whispers: “Hi Boo, someone told us you’re afraid of the dark. So we decided to help you by creating a bedside lamp.”
Living in the Material World
– Hello, you remember your uncle Mike, right?, says a weird one-eye monster, all green and round, passing the door.
– Of course, replies Sulley, she remembers us, Mike.
– Boo!, lovely confirms the young girl, reaching her hands to Sulley.
The fluffy blue beast hugs the girl in a pink pyjamas. Mike mumbles:
– Yeah, of course, I bring all the materials here and you take all the hugs.
– I heard you, friend, says Sulley holding the child. Boo, we came up with the idea to build a bedside lamp for you. A flashy one, so you won’t fear the dark anymore, ah. By the way — he turns on his fellow and asks — what did you bring?
The round and green monster points all items on the ground out, describing them like a robot:
- Adrafruit Metro Mini 328 5V 16MHz: https://bit.ly/2U9YThu — or any other Arduino board, bip.
- Adafruit NeoPixel 144 LED strip: https://bit.ly/2VsugoK — bip, bip.
- Momentary button: https://bit.ly/2KkOvDQ
- Mini breadboard: https://bit.ly/2VzTFNm
- Straps: https://bit.ly/2OWGdk9 — tchhh.
- Wires: https://bit.ly/2TZOyo4 — I’m a robot, bip, bip.
- USB cable with switch: https://bit.ly/2G21aWF — tchwwss, bip.
Sulley and Boo look at their friend, both embarassed in each other hands.
– Boo?
– Mike, why did you do..?
– Did what?
– That.
– What?
– That!
– That, what?
– Boo!
– Holy… Why did you mimic a robot?
– What? You didn’t like my imitation?
– Stop saying “what”, shouts Sulley.
Everything is connected
“Take it, stop playing like an idiot and help us” sighes the monster, holding this piece of paper to him:
Mike, despite his friend warning, describes the schema still like a robot:
- Tie board PIN 5V to NeoPixel 5V.
— tchhhh — PIN 6 to NeoPixel DIN.
— bip — Arduino PIN GND to GND strip. - Connect Arduino PIN 2 to one leg of the button.
— bip, bip — PIN GND of board to the other leg.
— twiiiik.
Surprisingly, the big blue beast doesn’t say anything. But few seconds later, he resumes with his loud voice:
– I have the perfect tool to weld it, laughing at his own joke.
– Will you stop to be silly?, grumbles his one-eye friend.
– You have zero humour, says Sulley, it’s the pot calling the kettle black. Well, let’s continue and weld them correctly. When we’ll finish Boo, you will have to write the Arduino code to enlighten your room.
Run, Forest, run!
– Oh my god, what is this? mumbles Mike in the back, approaching a treadmills.
– Hold on, my little pumpkin, continues Sulley to the girl. This part will be very, very difficult. I need you to be really focus, right? Do you think you can handle it?
Boo nods, slowly, with her glowing eyes, which reflect the giant monster. Mike, on the background, studies the dashboard of the jogging device: “Hum, hum, what is this button?”
– OK, kiddo. The code… I’m sorry, Boo, it will be hard to write… I’m not sure you can do it.
The child saddly lowers her head, disappointed.
– No, I’m kidding, shouts the blue monster. It’s the example of Adafruit NeoPixel LED: ButtonCycler. It’s open source, ah ah. However, you will need to change the number of pixels in the file:
#define PIXEL_COUNT 144 // Number of NeoPixels
– And remove the rainbow(int wait)
and theaterChaseRainbow(int wait)
method calls. Weirdly, we cannot find the gamma32()
method, Mike and I. So we simply change these calls to other colorWipe(uint32_t color, int wait)
with custom colors. Be carefull to also decrease int mode
counter to make it work.
Suddenly, a sound on the background is growing fast. The treadmills was starting!
Sulley and Boo, confused and surprised, turn around again to the materials.
– We did see nothing, OK?
– Boo.
– Yup, let’s continue, concludes the blue monster.
Strap Me If You Can
– You will stick the first face of the straps on the NeoPixel strip, resumes Sulley. The straps are adhesive on one side. Meanwhile, I will stick the other face on the bed, behind the bed frame top.
– Then, we need to strap the Adafruit Metro Mini on the bed frame, thanks to the mini breadboard.
– Boo!
– Well, Boo, I think we are ready, we can plug it with the usb cable.
With the Lights Out
“Boo, Boo, Boo” repeats, the girl, jumping in circle, happy, while the walls are painting in green. Sulley pushes the button. The strip changes its colors to blue.
The tall creature resumes:
– We also can create our own colors and animations. I changed the colors and the animation, also decreased the delay of animation.
– You can find my code, or create yours.
The young girl already jumped into her bed, amused.
– You can also add different modules, components, sensors. Imagine, shouts Mike from the back, a potentiometer to set the brightness of the LEDs. Or even better, imagine a wake-up morning lamp with colors based from the current meteo: blue for wet days, yellow for sunny ones…
When he speaks, Mike is running on the treadmills, proudly. Too proudly, maybe. And fast. Definitely too fast.
Mike comes back, out-of-breath, and leans on to his blue friend.
– Sulley, he tries to say between two breathes, we have to go. It’s late. She needs to sleep. Good night little Boo.
Affectously, the big fluffy monster kisses the headfront of the girl. The two creatures are passing the closet door when Sulley turns back:
– With this lamp, Boo, you won’t be afraid of the dark. Sweat dreams…