Introduction: Glowy Disco Badge

In this project we'll be making a fun glowy badge which lights up with different colours and in patterns which respond to your movement. Wear it to a party or a disco and bask in the admiration of all your friends!

The display is an Adafruit Neopixel ring, and according to your budget, you can use the 12- 16- 24- or even the 60-pixel ring. The video shows the 24-pixel ring and the 12- and 60-pixel versions are also shown in the pictures above.

The easiest way to house it is to slip it into a soft plastic ID badge holder but you could equally sew it to garment if you like, or use some other method. My 60-pixel ring is mounted on a piece of wood. This isn't very pretty (it was left over when I cut a hole in the back door for the cat flap!) but you could do better with a piece of acrylic.

The display pattern consists of a band of LEDs which light up on either side of the ring at the 3 and 9 o'clock positions. They respond as follows:

  • If you jump up and down, both bands move up and down.
  • If you rock from side to side, the two bands rock.
  • If you twist, the band on one side is red-shifted and on the other is blue-shifted.
  • The static colour gradually changes through the colours of the rainbow according to how much you move.
  • One LED flashes white, according to which way you're facing according to the compass.
  • If it detects no motion for 5 seconds it enters a set a sequence of moving patterns.
  • If you twist it sharply back and forth 3 or 4 times whilst holding it roughly horizontal it enters a calibration mode, allowing the magnetometer offsets to be determined.

Step 1: The Parts You Need

You will need the following active parts:

  • Arduino Pro Mini (5V 16MHz)
  • MPU-9150 Accelerometer and Magnetometer
  • Bidirectional 3.3/5V level converter.

Make sure they are as illustrated otherwise you will have to modify the layout. In particular, there is more than one type of level converter. The one I use is a 4 channel one (though we only need 2 channels). It has LV and Gnd as the middle two pins on one side, and HV and Gnd as the middle two on the other.

All of the above can be obtained cheaply from Far Eastern sellers.

For the display you will need:

  • Adafruit Neopixel Ring.

(There are similar but cheaper rings also based on the WS2812 chip or a clone, available from Far Eastern traders. These might work equally well but if you get a faulty one you might find it harder to get satisfaction from the seller.)

I recommend the 12 or 16 pixel ring to fit in a credit card size badge holder. The 24 pixel ring will just fit, but for that you may be better off with a 90x110mm badge holder. If you really want to go big, the project will equally drive the 60 pixel ring, but it won't then fit in a badge holder. You'll need to attach such a ring to a piece of wood or acrylic as it will need some kind of support. If you might want to extend or reprogram the project with a real time clock module to make a clock then the 16 pixel ring is best avoided.

You will also need the following miscellaneous items:

  • One piece of 65x95mm stripboard
  • Solid and stranded connecting wire.
  • 2.54mm female SIL header socket strip

Step 2: Tools

You will need to be able to solder, but that's not hard - there are plenty of Instructables and other materials online to get you started, such as this brilliantly simple and entertaining tutorial from Technology Will Save Us. Four of these badges have already been built by 12 - 14 year old schoolgirls with just a little supervision.

For tools, you will need wire cutters, wire strippers, small pliers and a track-cutting tool for stripboard, though with care you can use a small craft knife or scalpel. and of course, you'll need a soldering iron.

For programming you will need an FTDI232 serial/USB adapter and you will need to install the Arduino IDE on your computer.

Step 3: Adding Power

There are two ways of powering your glowy badge. If you have a rechargeable lithium power bank with a USB socket as designed for recharging a smartphone, you can use that. Get hold of a cheap USB charging or sync cable and cut off the unwanted connector. You can then solder the cut end directly to the stripboard, having made sure you correctly identify the 5V and Gnd wires.

The cheapest alternative is a 3V battery box taking 2 AA batteries, plus a 3 - 5V boost converter. If you use a converter (as shown) with a USB socket you can use it with a USB lead as above. Solder the red and black wires from the battery box to the IN+ and IN- pads (respectively) on the boost converter. Wrap them around the opposite end of the boost converter for strain relief, then insert it into a piece of heat shrink sleeving for protection. Warm with a hot air gun or hair-dryer to shrink the sleeving. Or you can wrap it in PVC insulating tape.

Step 4: Construction - 1

If you are using a credit card size badge holder, cut your stripboard to fit. It should then have 32 holes along the length of the copper strips and 20 holes across its width.

Using a stripboard track cutter or craft knife, cut the copper tracks at the positions marked by red dots in the diagram. To avoid mistakes you might like to mark the positions with a felt tip pen before starting to cut. (The components and the wiring to be fitted to the other side of the board in the next step are shown at 50% transparency.)

Before continuing, it's a good idea to examine the board with a magnifying glass to ensure that there are no remaining slivers of copper bridging any of the cuts, or bridging adjacent tracks.

To simplify programming, solder the SIL header socket strip to the 6 pads at one end of the Arduino Pro Micro (component side).

Cut 2 lengths of solid core wire around 3cm long, strip the insulation from one end of each, and solder them to the two pads either side of the pad marked A3, inset from the side of the board, soldering on the under side of the board. (These pads are harder to solder to after the Arduino is fitted to the board.)

Step 5: Construction - 2

Solder the Arduino Pro Mini, IMU and level shifter to the stripboard as shown in the diagram as follows.

Strip a few centimetres of insulation from some solid core connecting wire. Place the Arduino Pro Mini in the correct position on the board and thread the wire through the board and then through the Arduino at one of the positions marked by a purple dot. Solder the wire to the Arduino on one side and to the copper strip on the other, making sure the Arduino is seated flat on the board. Trim the wire on both sides.

Repeat for all the other purple dots on the Arduino, and then likewise for the IMU and the level shifter.

The two wires soldered to the Arduino in the previous step can now be trimmed to length, the ends stripped, and soldered in position as shown in the diagram.

Using the solid core wire, complete all the other connections shown in purple.

Solder the positive and negative leads from your USB plug or boost converter to the copper tracks marked Vcc and Gnd respectively.

At this point it's a good idea to double check your wiring, and that you don't have any slivers of solder bridging adjacent tracks.

Step 6: Construction - 3

Connect the NeoPixel ring. You can use solid core connecting wire but stranded is probably better. I like to use just 4 strands of rainbow ribbon cable. You will need around 150mm in length.

All NeoPixel rings have just 4 connections marked Power (or Vcc), Gnd, Data-In (or IN) and Data-Out or (OUT). If using ribbon cable, split the wires at one end sufficiently to reach the NeoPixel connections. Solder the 4 wires (or 4 separate lengths of connecting wire) to the 4 NeoPixel connections.

Now solder the other ends of the wires to the stripboard as shown by the green connections in the diagram in the previous step.

The diagram shows a schematic of the completed project.

Cut a piece of card to the same size as the stripboard and attach it to the copper side with blu-tack. If any wires are protruding from the copper side of the board sufficiently to pierce the card, trim them back with a cutter, or use thicker card or an old credit or loyalty card.

Now affix the NeoPixel ring to the card, also using blu-tack. The top pixel should be the one with the Data-In connection immediately to its right (as seen from the front of the ring).

Step 7: Programming

For this you will need a FTDI232 serial/USB adapter and the Arduino IDE installed on your computer. (If you have an Arduino Uno you can programme it with that instead.)

In your Arduino folder (by default under Windows this is in My Documents) create a folder called DiscoBadge. Into this folder, copy the 5 .ino files attached to this step.

You will need to download and install the MPU6050 library (this also
contains code for the MPU-9150, a superset of the MPU6050) and the Adafruit Neopixel library.

There is no need to modify these files to take account of which size ring you use.

Plug the FTDI adapter into the Arduino, double checking it's the right way round. (The labels on the Arduino should match those on the FTDI adapter.) Plug the FTDI adapter into your computer.

Launch the Arduino IDE, and under File-> Sketchbook, select DiscoBadge.

Under Tools -> Board, select Arduino Pro or Pro Mini.

Under Tools -> Processor, select ATMega328 (5V, 16MHz).

Under Tools -> Port, select the COM port that Windows has assigned to the FTDI adapter (you can determine this by launching Device Manager and looking under Ports (COM & LPT) ).

Under Tools -> Programmer, select AVR ISP.

Select Sketch -> Upload, or press Ctrl+U.

The sketch will be compiled and uploaded, and should start to run within a few seconds.

The FTDI adapter will power the board, but after unplugging it, it will require its own power supply.

Step 8: Calibration

The raw data from the magnetometer exhibits offsets which normally swamp the earth's magnetic field, and so these must be subtracted before North can be determined. The first tie you power it up it will enter a calibration procedure.

This project incorporates the procedure I described in a previous Instructable: Automatic Magnetometer Calibration Procedure. I give simple instructions in Step 4.

To summarise, whilst always keeping the edge of the board parallel with the edge of your desk (or some other fixed straight edge) level or tip the board so as to make all the pixels green. Blue pixels are too high (i.e. too close to the sky). You will be required to do this 15 times, 3 times at each of 5 different orientations.

Step 9: Going Further

If you wish to experiment further it's easy to modify many of the characteristics of the badge, such as its sensitivity to movement. All of these are set in #define statements in the file DiscoBadge.ino where you can easily edit them. In particular:

  • BRILL is the normal brilliance of the pixels and can be any value up to 255, but much above 30 will leave you with spots before your eyes! BRILL1 is the brilliance of individual brief flashes in one of the patterns, and can safely be made quite a lot higher.
  • JUMP, ROCK and TWIST define the sensitivity to vertical motion, rocking from side to side, and twisting.
  • SMOOTHING is the number of samples over which motion is averaged, in order to prevent excessively jerky display.
  • MINACCEL and MINGYRO determine the accelerometer and gyroscope readings below which the badge is considered stationary.
  • INACTIVITY is the number of milliseconds without movement after which the display reverts to changing patterns.
  • REVERSED indicates that the accelerometer and Neopixel ring are mounted on opposite sides of the board. Comment this out if you want them on the same side.

If you'd like to change the patterns displayed when there's no motion you can edit the file Patterns.ino with just a basic knowledge of C programming. Each pattern, of which there are currently 11, is in implemented in a separate function, and the functions are called in turn from a switch statement. You can easily change their order or the length of time each is displayed for, and with a bit more effort you can define new ones of your own.

This project makes a good basis for many others, possibly incorporating other sensors or modules, such temperature, humidity or light detection, real time clock or GPS modules. Inputs from these could be made to influence the display, or to implement completely new functions.

The code in DiscoBadge.ino allows for the addition of extra functions and will switch to the next (if any) on twisting the device back and forth 3 or 4 times while holding it vertically. For each new function, increase the value of MAXFUNCTION by one and add the function code towards the end of the function loop().

I've implemented another function in the Small Hadron Collider Instructable, and you can see it in action here:


Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest