In our code, the digital inputs D0 and D2 are used as switches. The pins are set to
INPUT_PULLUP mode, which means they will normally read
HIGH, until they are sent to ground by a button press, which will cause them to read
The program checks these pins and when one goes
LOW (is pressed) it broadcasts the tone for the appropriate duration, pauses for the gap duration, and repeats until the pin goes low again.
We can use any button as a key switch or pair of buttons as a paddle. If you want a more authentic paddle experience, you can build a simple one from a clothespin, a block of wood, two nails, rubber bands, and a bit of conductive fabric (or aluminum foil), some wire, and tape.
First, we'll make two contact switches on the clothespin. These will be two pieces of conductive material -- either conductive woven fabric, or aluminum foil -- which can be connected to the D0 and D2 pads on the Gemma M0, and which will be able to close the circuit to ground when they contact a nail connected to GND.
- First, cut two strips of the material to size so they'll each wrap around the ends of the clothespin
- Next, place a piece of double stick tape on the material, leaving a bit of extra material on one end for connecting your wires
- Press the material strips to the ends of the clothespin as shown
- Wrap the material around to the inside as well -- this is where it will contact the nail
Now, we'll make the base for the keying paddle, by fastening the clothespin to a small piece of wool with a nail, and driving in another nail for the ground contact.
- Measure and mark a point in the center of the board's width (1-1/4" from either side) and 3/4" up from the bottom edge
- Place a nail through the clothespin's spring coil and hammer it into this marked point as shown -- be careful not to hammer too deeply or the clothespin won't be able to rotate
- Mark a point in the center of the board's width, about 2" up from the bottom edge -- this should be right in the middle of the clothespin's legs
- Hammer in the other nail as shown
This is the point either paddle contact will touch when pressing the paddle from either direction.
We want the paddle to return to its home position after every tap. To do this, we'll use a pair of rubber bands pulling equally to the left and right on the clothespin.
- Squeeze the clothespin open
- Loop one rubber band around the left side of the clothespin head as shown
- Twist the band to capture the head, then wrap it around the wooden board base as shown
- Repeat this for the other side
You may need to pull each band left or right to adjust it and get the clothespin legs centered an equal distance apart from the contact nail.
Now you can tap the paddle from either side and test out the action! It will contact the nail and then return to home position.
We'll now wire the D0, D2, and GND pads on the Gemma M0 to the left, right, and ground contacts respectively on the clothespin conductive material and contact nail.
This is what the circuit looks like using regular buttons, but our contact switches will serve the same purpose as these buttons. We'll add an antenna wire later.
- Plug the Gemma M0 into the battery box, then secure both to the end of the board with a rubber band or tape
- Connect the Gemma M0's GND pad to the contact nail with an alligator clip lead (or twist the ends of solid core hookup wire or stranded wire around the pad and the nail if you don't have alligator clip leads)
- Connect a wire from the Gemma M0's D2 pad to the conductive material on the right leg of the clothespin paddle
- Connect a wire from the D0 pad to the left leg conductive material
If you're eager to test your progress so far, you can turn on the battery's on/off switch and tap the paddle in either direction -- you will see the on-board LED light up for a long dash when you press with your index finger, and a short dot duration when tapped with your thumb.
But, before we can hear anything transmitted over the AM radio waves, we need to build an antenna.