A little lightbulb that shines brightly when you raise it! When it's upside-down on the table, it flickers with a soft amber light. Could be a night light, or just a fun desk accessory.
Moheeb and I have a history of building weird lightbulb projects, so when I was at the Neon Museum I picked up a couple of glass souvenir ones, for future hack nights. When Lindsey from TinyCircuits contacted me about their new accelerometer and NeoPixel-compatible LED modules, this project seemed like a perfect way to show off their minuscule size! Lindsey kindly sent enough for two, and we got to work late one night at the Hackster office.
The BuildThe board uses a BMA250 accelerometer chip, and the version we got can actually serve several different purposes, as shown by the checkboxes on the back.
Moheeb put together the physical build for this, wiring up the I2C accelerometer module to the TinyLily on pins A4 (SDA) and A5 (SCL), as well as power and ground. Then, he connected the NeoPixel to pin 3 (which has the PWM capability to drive it) and ground. In summary:
Accelerometer:
- A4 — SDA
- A5 — SCL
- Power & Ground
NeoPixel:
- A3 — Data
- Power & Ground
We stuck the two modules back-to-back, with double-sided foam tape, so they wouldn't collide and short out. The accelerometer board is oriented so that the X axis is straight up-and-down.
The TinyLily is connected to a battery module, which attaches to a coin cell battery – enough to power the entire assembly! Moheeb put the battery holder at the top of the bulb, where it screws together, and we were able to fit all the modules through the tiny neck of the glass lightbulb, to create a self-contained unit....And of course, we put in a switch!
To power this project, Alex mashed up some NeoPixel example code (included when you install the library): Examples > Adafruit NeoPixel > simple
...with the accelerometer code Lindsey linked me to on GitHub.
This sketch should scale easily if you choose to add more pixels inside.
We ran into a problem where the Arduino serial monitor seemed to just give us garbage instead of the accelerometer values. This was because I had the wrong Arduino processor settings – it was set to "ATmega328P (5V, 16 MHz)". They should be:
- Board: "Arduino Pro or Pro Mini"
- Processor: "ATmega328P (3.3V, 8 MHz)"
- Programmer: "Arduino as ISP"
After fixing that, we got beautiful data streaming live from the accel board!
After we got that running, Alex added in the NeoPixel code to wipe an amber light across all LEDs, with its brightness based on the vertical accelerometer axis – in this case, we used the X axis, but it depends on which way you orient the accelerometer within the bulb. For best results, make sure that the chip is pointing directly up and down along that axis.
More cool stuffTake a look at our Thinker Blinker for a similar project, controlled by your BRAIN via a Muse EEG sensing headband!
Also, this is sort of like a high-tech version of Alex's tilt-switch based Lego Lamp, so if you like cool little night lights, check that out too. :)
Comments