Passing Secrets

Any proper spy will find the need on occasion to pass secret information along to an ally securely. There are many techniques to do so — sometimes, they can be highly technical, such as an encrypted digital message, but other times they may need to be decidedly simple and low tech -- hiding information just outside of plain sight can be very effective.

For example, you can write an innocuous-looking letter that will pass scrutiny should it be seen by enemy eyes, yet have top secret information written in invisible fluorescent ink! Your intended recipient can use an ultraviolet (UV) light to read the message!!

In this project we'll use your Gemma M0 to create a touch-sensitive UV light illuminator. Plus, you'll learn a little coding with so this is a great way to make your first spy project

Materials and Parts

You'll need some paper and an invisible UV marking pen, as well as the parts listed below.

1 x Gemma M0
Tiny microcontroller
1 x UV LED
UVA/Purple 5mm LED
1 x USB Cable
Micro USB to USB A
1 x 3x AAA Battery Holder
with JST connector and ON/OFF switch
1 x USB Cable
A/MicroB - 6"

Additionally, you'll use two M3 x 8mm screws and nuts to connect the LED to the Gemma M0.

Hide in Plain Sight

Ultraviolet marker pens use ink which lacks color pigment, so it doesn’t leave a mark visible to the naked eye under normal lighting conditions. However, when illuminated with a UV light source (sometimes called a blacklight), it fluoresces brightly. This is easiest to see in dim lighting conditions.

A nice, compact source for UV light is a UV/Purple LED which emits light in the 400nm wavelength. This is right at the edge of the visible light spectrum, so you will see a purple glow cast from it, but it is a long enough wave to excite the fluorescent material and reveal the secret message.

Build the UV Light Decoder

With a forward voltage of 3.4V DC, you can power the UV light very well with the 3.3V output of your Gemma M0. No resistor required! We’ll connect the short, cathode leg of the LED to the GND pad and the long, anode leg to the D2 pad.

Coil each leg so that it will fit an M3 screw as shown here -- be sure to pay attention to the which is the long, anode leg so you can connect them properly in the next step.

  • Fit the LED leg coils over the respective pad holes on the Gemma M0 -- long, anode leg to D2, short, cathode leg to GND
  • Push the screws through the pads and LED coils as shown
  • Thread the nuts onto the screws

Next, we’ll code the Gemma M0 to light up the LED when we press the D0 capacitive touch pad!

Coding Options

You've got lots of options when it comes to coding the Gemma M0! You can use Arduino, CircuitPython, and MakeCode. For this project we'll use the drag-and-drop GUI interface of MakeCode to quickly and easily build our program.

Create a MakeCode Project

First, head to the Maker.MakeCode site in your web browser. This version of MakeCode is in beta as of the writing of this guide, and it expands the available boards beyond the Circuit Playground Express to include the Gemma M0, Trinket M0, Metro M0 Express, and Feather M0 Express. 

Click on the Gemma M0 image to select it.

Now, click the New Project button to create a new program using the Gemma M0.

Building Blocks

This is the default MakeCode screen. On the left is the simulator which can be used to test your program before uploading it to the Gemma M0.

In the center is the palate of programing block categories.

On the right is the canvas where you'll drag blocks to create your program.

Click on the forever block to select it, and then press delete on your keyboard to get rid of it, we won't need it for this program because everything that happens will be triggered by an input action.

Then, click on the input category to expand it and drag the on touch D0 click block onto the canvas. 

Touch Input

You'll see that there are a couple of drop down lists on this input block that you can use to adjust the behavior. You can choose between touch and button modes for each of the three pins on the Gemma M0 -- D0, D1, and D2. We'll leave this in the default setting of touch D0.

You can also fine tune the input so that it reacts to one of four states -- click (which means press and release), long click, up (just the release action by itself), and down (just the press action).

Since we want to hold the D0 pad to light the UV LED, and then release it to turn it off, we'll change this dropdown from click to down.

Simulator Update

Notice, when you add this input block, the simulator updates to reflect the new circuit. While it has built a button wired through a breadboard in this case, and we are actually going to use the capacitive touch, it is a pretty interesting and helpful graphical layout nonetheless.

Turn On the Lights

Now we have an input block that can detect when the D0 capacitive pad is touched, but it doesn't actually do anything when pressed. Whatever action block we drag inside the on touch block is the action that will occur.

From the Pins category, drag a digital write pin D0 to LOW block onto the canvasdigital write command sets a pin either HIGH to enable 3.3 volts on the pin, or LOW which sends the pin to ground.

Drag the digital write block inside of the on touch input block. Since we want the LED that we'll plug into pin D2 to turn on when the D0 pad is touched, change the dropdown to pin D2, and switch the state slider from LOW to HIGH.

You'll see that the simulator has added an LED to represent the digital write command -- press the button on the breadboard to see it light up!

Release the Hounds

You'll notice that once you release the button, the simulated LED stays lit. This is because there is no command currently telling it to do otherwise! Let's add an input that tells the LED to turn off when your finger is "up" off the touch pad.

Duplicate the on touch D0 down block by right mouse button clicking on it and choosing Duplicate.

The duplicated block set will be greyed out because it is an identical input to the existing one, which is not allowed. 

Change the condition from down to up.

Lights Out

Now, you can tell the digital write to go LOW when the touch pad is released, or "up". 

Test out the simulator -- now the LED will illuminate when you push the button down, and turn off when you release the button.

Name It & Download It

Give your project a meaningful name, such as, oh, I don't know, "Gemma_UV_Reader", and then press the download button.

When prompted, save the file to a memorable location. This file is a .uf2 (USB Flashing Format) file which we'll use in a moment to flash the Gemma M0 with the new program.

Upload the Code

Now you can put the code on your Gemma M0! Plug the Gemma M0 into you computer with the USB cable. After a moment it will be recognized by your computer as a USB drive. (If it doesn't show up, make sure the Gemma M0's power switch is in the ON position.)

It should show up with the name 'CIRCUITPY'. In order to upload the new program, double click the reset button on the Gemma M0 -- the red onboard LED will start to pulse and the USB drive will show up named 'GEMMABOOT'.

Drage the .uf2 file onto the GEMMABOOT drive.

After the file transfers, the Gemma M0 will reboot, and the program will run. Unplug it from the USB cable, and get ready to try it out!

Plug in the AAA battery holder to the Gemma M0 and turn on the battery pack's power switch. Be sure not to touch the capacitive pins on the Gemma M0 while it is starting up, as there is a capacitive touch calibration that runs to get a baseline value.

Once it has started, touch the D0 pad and you'll see the LED light up!

Invisible Writing

Use your UV marking pen to write a secret message on a piece of paper, or page of a newspaper or book. The naked eye won't see any indications of the writing. Now you can send the message along to a compatriot, and nobody snooping around will be able to see your important intel...

Let There Be (Ultraviolet) Light

Then, by deploying the UV reader, the message will be clear!

Especially if you turn out the lights first! This composite photo shows the full message at one time -- you'll need to reveal each letter one by one, unless you and your fellow spies have very small handwriting!

Unlike the old lemon juice and light bulb trick -- the marker ink isn't "developed" it fluoresces under UV light -- if you hear someone coming, lift your finger off the cap touch pad and the message will disappear!

This guide was first published on Mar 16, 2018. It was last updated on Mar 16, 2018.