Flashy Morse Badge



Foreward

At this date (8-Jun-2014), I haven't quite completed this document. You can download the software here. I still haven't gotten any photos, and likely won't for a couple of months, but decided to put this onto my website so you can play with it. Hopefully I'll be able to get this done in August.

You can also grab the list of parts (called a "bill of materials").

Background

This project was inspired by the paper adhesive badges that say "Hello, my name is" and space for you to write in your name. I decided I wanted something a bit, well, more flashy. So I came up with the Flashy Morse Badge, which flashes a message in Morse code. Mine says "HELLO I AM CLARK KI7TU" — Morse code not having lower case. (By the way, KI7TU is my Ham Radio callsign.) You can change yours to whatever string you want, within the restrictions of what can be represented in Morse code. (Actually, I didn't encode any punctuation, so if you want it, you'll have to add it.)

Overview

Briefly, it has a tiny computer board, three controllable RGB LEDs, a light measurement device (to set the brightness of the RGB LEDs), a bar pin to attach it to clothing, and a battery holder. The battery holder provides power, an on-off switch, and serves as a structural foundation to hold the other parts of the Flashy Morse Badge.

The tiny computer board is (somewhat) Arduino compatible. It is programmed using the Arduino IDE, but it has far fewer I/O pins than a true Arduino. It also lacks the serial I/O and true USB interface. It does have a bootstrap program that allows it to fake the USB enough to load a program, but it can be a bit finnicky. The reduced feature set allow it to be both physically smaller than a normal Arduino, and significantly less expensive. Because it is a bit finnicky to program, though, it may help if you have some experience with a real Arduino.

A few details

The badge is built on a 3xAAA Battery holder (#727) from Adafruit Industries (adafruit.com). It provides the overall base for building the badge, as well as acting as a holder for the three AAA cells and has a convenient switch for turning the badge on or off. Eventually you'll need to amputate the JST connector, but more on that later.

Construction

Note: Before starting actual construction, please read though both this section and the one entitled "Theory of Operation" as it will explain some things that might seem a bit strange without that understanding. Also, please look at the Fritzing diagram below of the circuit. (I'm not a real expert with Fritzing yet, as this is my first attempt to use it, and the computer I'm using at the moment is not the ideal platform to be doing any sort of graphics on.) Note that it is NOT to scale!


Flashy Morse Badge - NOT to scale!

We'll start by assembling the three NeoPixels. If you examine them closely, you'll note that they each have four holes for soldering (or otherwise attaching) connecting wires. One of the holes is marked with a + sign, and the one opposite it is marked with a - sign, though that's harder to spot. One of the other two holes has an arrow pointing to the LED, and the hole opposite has a small arrow pointing away from the LED.

A Word about Wires

Wires for this project should be (about) 22 gauge stranded. You can get assortments (or individual spools) of 22 guage stranded wire from many sources, such as SparkFun or your local hardware store. Alternatively, you can cut up jumpers such as these from SparkFun or these from Adafruit. I recommend that if you do cut up jumpers, leave an inch or so on each pin – they can come in handy in the future to adapt things to solderless breadboards. I also strongly advise that you not use solid wire, such as comes with many solderless breadboards.

To wire up the NeoPixels, we start by wiring together the + holes on all three of them, using enough wire to space them so that there is about 1/4 inch (5 to 6mm) between the nearest edges, with the NeoPixels arranged so that the + holes are all on the top as you look at them. The overall length of the string of NeoPixels needs to be around 2.5 inches (about 65mm). It doesn't have to be really accurate, but the distances should be roughly even. (The common "standard" is to use red wire for the + lines, but if you don't have any red, use whatever color you have.) Be careful to not fill the hole on the one on the end where the arrow indicating "data-in" is located, as we'll need to solder an additional wire to this one. Do the same for the - holes on all three, making sure that the orientation of them is the same. (Black wire would be "standard" for this lead, but again, use what you've got.)

For convenience, let's call the NeoPixel that has the "data-in" away from the other two NeoPixels as LED 1, the one in the middle LED 2, and the last one LED 3.

The "data-out" connection (the one with the arrow pointing away from the LED) on LED 1 needs to be connected to "data-in" (the one with the arrow pointing towards the LED) on LED 2. Likewise the "data-out" on LED 2 needs to be connected to the "data-in" on LED 3. You should use some form of small gauge stranded wire for this. I tried using conductive thread, and did get it to work on my Flashy Morse Badge, but it doesn't take solder well (OK, it doesn't take it at all). I had it handy and wanted to try it. I'd suggest you use a stranded wire with a different color than the + or - wires, maybe blue.

Next wire the + on LED 1 to the Vcc connection on the Analog Light Sensor. Use a piece of wire about half an inch long, enough that you can make a graceful "U" with the Analog Light Sensor about a quarter of an inch to the + side of LED 1. A somewhat longer wire, about an inch long, should be used to connect the - on LED 1 with the GND on the Analog Light Sensor.

Now you need to solder wires on the Vcc and GND pads of the Analog Light Sensor that are long enough to reach around the battery holder to the Trinket's 5V pad (for Vcc) and the Trinket's Gnd pad (for GND). Remember when doing this that the front panel, where the NeoPixels and Analog Light Sensor will be mounted, will need to move about 1/8 inch in order to get to the batteries to change them. A wire needs to run from the "data-in" pad of LED 1 to the pin labeled #0 on the Trinket (I used blue for this one). One wire needs to go from the "OUT" pad on the Analog Light Sensor to the Trinket pad labeled #2 (I used orange for this one). Again, remember to leave enough slack to open the battery holder.

The last wiring task is to cut off the last few inches of wires from the battery holder (which also amputates the JST connector). Leave enough for the red wire to reach the Trinket's BAT connector and the black wire to reach the Trinket's Gnd connector. I think it's best to not put batteries into the battery holder until after you've programmed the Flashy Morse Badge. This guarantees that you don't have battery power applied when trying to program the Badge.

Loading the software

Once all of this soldering is done, I think it's best to use the Arduino IDE to load software into the Trinket computer before going on with the mechanical attachmens. That way, you can test the bits and pieces, and make any fixes without having to worry about melting the plastic case.

The Trinket has some differences from a normal Arduino that require some changes "under the hood" on the IDE. Fortunately, you can download a version of the Arduino IDE that has already had the modifications made. You can get it by cliking here, though you probably should check the document mentioned below to see if there's a more recent version. (You can find out more about the Trinket by reading Adafruit's Introducing Trinket document, as well as making sure that you have the latest version of the IDE.)

You'll also need to get the NeoPixel library from Adafruit. Please see the "Arduino Library" section of the Adafruit NeoPixel Uberguide for instructions on downloading and installing it. There are a few things you have to do, and there's no point in me replicating those directions here.

Once you've got the Arduino IDE up and running, please look under the Tools menu and find the Board submenu, and under that select "Adafruit Trinket 16MHz". Also make sure that the Programmer submenu (also under Tools) has "USBtinyISP" selected.

Open the morse_badge file, and find the line that looks like this:
const char send_string[] = "HELLO I AM CLARK KI7TU  ";
and change it to your name and call sign. (If you don't have a call sign, please delete mine. You can get info on getting an Amateur Radio license at www.arrl.org -- and by the way, you no longer have to learn Morse code to get one.) The two spaces after my call sign cause it to delay a little bit between repetitions of the code.

Once you've done that, use the Verify button (the one that looks like a check mark) to make sure the code will compile cleanly. Often times, running the compiler the first time takes a few more seconds than it takes to run it the second and subsequent times when you start up the Arduino IDE. If you get a bunch of error messages, scroll up in the error section to see the first one. If it says something like "morse_tables.h: file not found" please use Windows Explorer (or Command Prompt, if you're comfortable with that) to verify that the file is in the same folder as the actual morse_badge "sketch" (which, by the way, is stored with a file type of .ino). As a double-check, when you're looking at the morse_badge file in the Arduino IDE, you should also see a tab for the morse_tables.h file. If you don't find it there, please locate it (maybe download it again), and put it in the same folder (careful, don't get it one folder up!). If you have to move it, you'll have to exit the Arduino IDE and then go into it again to have the Arduino IDE find it. (Be sure to save the sketch before exiting the IDE, or you'll lose your changes to it.)

Now it's time to actually load the software into the Trinket. Due to some limitations of the Trinket hardware, this can take a few tries, especially if you have a rather slow computer, as you have to use the Trinket's RESET button to put it into bootload mode, and it drops out of that in a few seconds. You need to time releasing this button so that the Trinket is in the bootload mode when the IDE gets ready to load software to it. I suggest if you think that the software might have gotten loaded, observe the red LED on the Trinket -- after the Trinket drops out of bootload mode it will start flashing the Morse code message if the programming was successful. If you also managed to wire the NeoPixels and Analog Light Sensor correctly, the NeoPixels will start displaying the message too. Be aware that for a "dit" only the middle NeoPixel will turn on, but for a "dah" all three NeoPixels will turn on.

If, for some reason, you want to change some of the code, here's a trick to verify that you have actually loaded the new version to the Trinket. Go down to the section where it says
void loop()
{
which are down near the end (roughly line number 180), and then look for the lines that say
#ifndef SEND_LIGHT_LEVEL
  switch ( color_cnt ) {
    case 0:
and change the "case" to 1 and also change the
    case 1:
a few lines further on to be 0. This will cause the Flashy Morse Badge to show red first, then white, rather than the other way around. For further changes to the code, change them back.

After you have the Trinket up and running, and flashing the NeoPixels, experiment a little bit to verify that the light sensor is working. Remember, it ONLY senses between repetitions of the message. If you put your finger over it, the NeoPixels should get a bit dimmer (assuming you're not in a fairly dark room already), and if you arrange for the sensor to see more light (for instance, by shining a flashlight on it), the NeoPixels should be brighter.

Final Assembly

Now that you've tested your Flashy Morse Badge, and it's working, it's time to do the final assembly. The bar pins usually have an adhesive foam strip already attached. Before you pull off the protective covering, take a moment to familiarize your self with the functioning of the pin. At one end they have a little rotating part that closes off the slot for the pin. Examine this closely as sometimes they need a little squeezing using a pair of pliers so that it doesn't come off. Be careful, though, to not get it so tight that it is hard to operate. Also, I've found it best to arrange the pin so that the rotating bit is in it's "closed" position when it's pointed down. This makes gravity your friend on keeping the badge in place.

OK -- lay the battery holder on the table with the switch on the side towards the ceiling. I like to have "Off" be down, so I selected the side towards "On" as the top edge of the badge. Peel the protective paper off the bar pin, and once you're sure of the orientation, and have aligned it with the top edge of the badge, maybe 1/16 inch (or 1mm) from the edge, press it on firmly.

Cut small pieces (roughly square) of the double stick foam tape, and put one on the back of each of the NewPixels and the light sensor. Leave the backer on for the moment. Cut a little bit larger piece, and put it on the back of the Trinket.

I'd do a "dry run" to see exactly how the Trinket is going to fit on the back of the battery holder. Place the Trinket in the lower right-hand corner of the battery holder, as viewed from the back (the side with the bar pin). It should be close enough to the edge that you can easily insert a USB micro connector if you ever need to reprogram it, but far enough back so that it's not visible when viewed straight on from the front. When you're satisfied with the position, peel off the protective paper from the double stick tape and adhere it to the battery holder.

Turn the battery holder over, so that the bar pin and Trinket are on the table side, with the bar pin away from you (so the "top" of the badge is away from you).

Now do a "dry run" with the light sensor and the three NeoPixel LEDs. The center line of the LEDs should be about 1/3 of the way down, and the center line of the light sensor will be about 1/3 of the way up from the bottom. Carefully remove the protective backer paper from the bits of double stick tape on the LEDs, and being careful to get them in a straight line, evenly spaced, and even from te top of the battery holder, stick them to the cover of the battery holder. Remove the backer from the light sensor, and adhere it to the lower left corner of the cover.

Examine your Flashy Morse Badge, and if you got any of the wires too long, make small bends in them to take up the slack and use tiny pieces of double stick tape to keep them from flopping around. (You could also use small dabs of hot-melt glue for this purpose, but when I built the prototype the tape was handy, and the glue gun was in the other room.)

Theory of Operation

Please don't be scared off by that big word "theory". It just means that this section explains the ideas behind how things work.

NeoPixels

Before going further, let's talk a bit about how the NeoPixels work: the processor sends a series of pulses that have the one or zero encoded by where the falling edge of the pulse occurs. Basically this amounts to a Pulse Width Modulation (PWM) scheme. In this case, the pulses are sent at 800 kHz. Each of the NeoPixels presumes that the first 24 bits that it sees are for it (8 each for Red, Green, and Blue, though not in that order), and so gobbles them up, and then passes along any remaining bits that it sees. So in our case, the NeoPixel (electrically) closest to the Trinket will grab the first 24 bits, and pass the next 48 bits on. The middle NeoPixel will then grab the first group of 24 bits that it actually sees, which are the second group of 24 that the Trinket sends. Both the first and second NeoPixels will pass the third group of 24 bits from the Trinket on to the last NeoPixel. Once all of three NeoPixels have their data, they look for a period of no actiity for 50 microseconds, and then execute the change to the new color. With a processor with more memory, such as an Arduino Uno, they say you can control more than a hundred NeoPixels on a serial line without noticable flicker. To get the speed to keep up with that 800 kHz bit rate, you do need to have a processor operating at 16 MHz. The NeoPixels also need to operate on a 5V data line, so the 5V Trinket works fine. (I think you could use a 5V Arduino ProMini as an alternative, but it has more I/O and is thus physically larger, as well as costing a couple dollars more than the Trinket.)

Trinket

The Trinket computer from Adafruit (part #1501) was designed to be both small and low cost. Their goal was to produce something that was low enough cost that you could easily afford to leave it in a project, rather than tearing apart one project to get parts for the next project. The Trinket is limited as to memory size, with only 8K of flash (some of which is taken up by the boot loader), and only has a total of 5 I/O pins (two of which are used by the boot loader to emulate a USB port).

There is no true USB port, unlike the true Arduino computers. When the Trinket is rebooted (or powered up) the boot loader is invoked and flashes the LED indicating that it is ready to load a new program. After a few seconds, if the boot loader program doesn't see anything that looks like a computer trying to load code to it, it drops out and executes whatever user program is in flash memory.

Since there's no real USB port, there also is no serial monitor capability like the regular Arduinos have.

Note that there are two "flavors" of Trinkets: the 3.3V version that can only run at 8MHz, and the 5V version that can run at either 8MHz or at 16MHz. The NeoPixels require 5 volts, as well as needing to be fed by a 16MHz processor, so the 5V Trinket is the one we want.

The Trinket lists for $7.95, as opposed to about $24.95 for the Arduino Uno. The Uno has 32K of flash memory, and 20 I/O pins, but for this project, the Trinket has plenty of capability.

Morse Code

The timing that is used for the Morse Code comes from a document from the American Radio Relay League (ARRL). The document actually is an article in QEX magazine from 1990, but it includes a box entitled "The ARRL Morse Tramsmission Timing Standard" which explains the actual timing. Although this latter document talks about using something called "Farnsworth timing" at speeds below 18 words per minute, I chose to stick with "Standard timing". (Farnsworth timing simply sends the actual characters at a higher speed, and increases the spacing between them to get slower speeds. It works well in training people to increase their speed when listening to code, but I think it can get confusing when used for optical transmission.)

This Screen Last Updated: 08-Jun-2014

Copyright © 2014 By Clark Jones