Updating my Programmable Jam Jar Light for a Camping Trip

Jam Jar LightA few months ago I created a Jam Jar light with a programmable weatherproof RGB NeoPixel strip from Adafruit. It’s a simple, fun, interactive gadget for short camping trips that helps me see at night. Using a bit of code that I placed on a Flora micro controller, and an accelerometer and a compass, the jam jar’s orientation relative to the local magnetic field determined its colour, and giving the jar a good shake turns the lights on and off.

When I took the little gadget camping with me back in February, I decided it needed a few modifications, which I just got around to finishing last weekend.

  1. Rather than having the colour of the lights fixed when the jar is stationary, the colours now very slowly cycle through red, green, and blue. I find that the jar is more relaxing when the colours are slowly changing.
  2. It was hard to adjust the brightness of the lights on the campsite without getting into the code, so now they’re adjusted by turning the jar: the local magnetic field changes the brightness according to the function B = (tan-1(Mx/My)/π + 1)/2, where Mx and My are components of the local magnetic field. The number B ranges from 0 to 1: when B is close to zero, the lights are off, and when B is close to 1, the lights are at their maximum brightness.
  3. The acceleration threshold was a bit too low: whenever the picnic bench jiggled, the light would turn off/on. So I doubled the threshold that determines whether the lights turn off/on.

The revised version of the code is up on a GitHub repository, I took a few pictures of the device on my Flickr photosteam, and the video below gives you an idea of how it works.

 

This entry was posted in Electronics, Hobbies and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s