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.
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.
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.
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.
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.