CW Controlled Arduino

Updated 2016-03-11

Introduction

This project allows you to remotely control an Arduino with CW (Morse code).  It is in beta status.

The idea is you can feed it a CW keying line from anything (a twisted pair, a tank circuit detecting RF, a receiver, a transmitter CW keying line) and have the unit turn things on and off using digital I/O lines. It’s intended to remotely control stuff.

I got the idea of using this with remote antenna switches. I’m not sure if this will work, but I want to make a tank circuit with a little whip antenna and a FET amplifier. When there is RF detected it will key the Arduino CW input pin on and off. So I can use RF emitted from antennas nearby at my QTH to command the Arduino to turn I/O lines on and off, wirelessly.

Operation

To get the unit to respond to commands, you first need to send the unlock phrase, defined in the code by this line:

#define UNLOCK_PHRASE "VVVDEK3NG"

When the unit unlocks, the Arduino LED on pin 13 lights up. You can then send whatever CW commands you have defined in code to turn pins on and off. This is defined here:

String control_phrases_pin_high[] = {"PIN4ON", "PIN5ON", "A"}; // ON commands 
String control_phrases_pin_low[] = {"PIN4OFF","PIN5OFF", "B"}; // OFF commands
uint8_t control_phrases_pins[] = { 4, 5, A0}; // pins

So, you could send PIN5ON to turn on pin 5, send A to turn pin A0 on, send B to turn pin A0 off, etc. You can define as many pins as you want for on/off command. Be aware that the code matches the first string it finds, so if you define commands “AA” and “AAA”, only AA will ever be matched and executed.

The unit will stay in unlocked mode for up to 60 seconds by default. If you make a mistake while sending a command, you can wait 4 seconds for the receive buffer to clear, or send a bunch of dits to clear it out and start over. There is no need to clear the buffer if you mess up the unlock phrase, just start over and send it again from the beginning. Various settings for timeouts are here:

#define UNLOCK_INACTIVITY_TIMEOUT_MS 15000
#define UNLOCK_HARD_TIMEOUT_SECS 60
#define BUFFER_INACTIVITY_TIME_MS 4000

I plan to add a sleep mode shortly so the unit can remain in low power hibernation until the CW line goes active. This would support totally wireless operation using batteries and/or solar power.

Like my other projects, there are various DEBUG options you can compile in and get helpful messages out the serial port. The received CW is also echoed out the serial port.

I have included an option for using the Goertzel audio decoder library, similar to the CW decoder built into the keyer project. To use this you need to couple receiver audio into an analog pin, biasing it at 2.5 volts using a voltage divider and coupling the audio with a capacitor. (I used two 10K resistors and a 0.1uF cap.)

Code

Code is available on Github.