Morse beacon with keying circuit
Build it step by step
0 of 6 doneWire the sidetone
Connect the passive buzzer to D9 and GND and upload the sketch.
Check the timing
Listen at 12 WPM: a dash is three times a dot, and a letter gap is three dots.
Change the message
Edit MESSAGE and WPM and upload again.
Wire the optocoupler
Add the 330 Ω resistor and PC817 as in the table, leaving the output side open.
Check the LED
A small LED in place of the optocoupler would flash in time with the buzzer.
Use the key line (licensed users)
Connect pins 3 and 4 to the key jack of a rig you are licensed to use at low power into a dummy load first.
How do you build a morse beacon with keying circuit?
An Arduino plays a repeating Morse message on a buzzer and can key an amateur radio's key jack through an optocoupler. You need Arduino Nano, Passive buzzer, Optocoupler PC817, Resistor 330 Ω, Resistor 1 kΩ and Breadboard 830 Tie Points. It takes 6 steps and about 45 minutes.
- Level
- Beginner
- Time
- About 45 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Nano × 1
- Motors & ActuatorsBuyPassive buzzer × 1
- SemiconductorsBuy
- PassivesBuyResistor 330 Ω × 1
- PassivesBuyResistor 1 kΩ × 1
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Nano D9 | Passive buzzer + | Sidetone |
| Passive buzzer - | Nano GND | Return |
| Nano D8 | 330 Ω resistor then PC817 pin 1 (anode) | Drives the optocoupler LED |
| PC817 pin 2 (cathode) | Nano GND | Return |
| PC817 pin 4 (collector) | Radio key jack tip | Isolated key line (optional, licensed use only) |
| PC817 pin 3 (emitter) | Radio key jack sleeve | Isolated key line (optional, licensed use only) |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Practise with the buzzer only. The key line is for connecting to the key jack of a radio whose owner holds an amateur licence, and you may only transmit with your own call sign within the rules of your country. The optocoupler only switches a key line of a few milliamps, never a transmitter's power.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const byte KEY_LED = 8, BUZZER = 9;
const int WPM = 12; // words per minute
const unsigned int DOT = 1200 / WPM; // dot length in ms
const char MESSAGE[] = "VVV DE YOURCALL"; // replace with your own message
const char* TABLE[] = {
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--",
"-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."
};
const char* DIGITS[] = { "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----." };
void key(bool on) {
digitalWrite(KEY_LED, on);
if (on) tone(BUZZER, 600); else noTone(BUZZER);
}
void sendSymbol(char c) {
key(true); delay(c == '.' ? DOT : 3 * DOT);
key(false); delay(DOT);
}
void sendChar(char ch) {
if (ch == ' ') { delay(7 * DOT); return; }
const char* code = 0;
if (ch >= 'A' && ch <= 'Z') code = TABLE[ch - 'A'];
else if (ch >= '0' && ch <= '9') code = DIGITS[ch - '0'];
if (!code) return;
for (const char* p = code; *p; p++) sendSymbol(*p);
delay(2 * DOT); // 3 dots between letters in total
}
void setup() {
pinMode(KEY_LED, OUTPUT);
}
void loop() {
for (const char* p = MESSAGE; *p; p++) sendChar(*p);
delay(5000); // pause between repeats
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Upload with VVV DE message | Buzzer plays the Morse |
| WPM set to 20 | Faster code |
| WPM set to 5 | Slow practice code |
| Pins 3 and 4 measured with a meter | Short circuit while the buzzer sounds, open between |
If it does not work
Buzzer plays a steady tone
A passive buzzer needs tone(), check D9 and that noTone is called.
No keying on the optocoupler
Check the LED side polarity and the 330 Ω resistor.
Letters run together
Check the 2-dot delay after each letter.
Radio never keys
Check the key jack polarity and that the radio uses a simple closing-to-ground key line.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the morse beacon with keying circuit?
Arduino Nano, Passive buzzer, Optocoupler PC817, Resistor 330 Ω, Resistor 1 kΩ and Breadboard 830 Tie Points.
How long does the morse beacon with keying circuit take to build?
About 45 minutes for a beginner maker, in 6 steps.
How do I know the morse beacon with keying circuit works?
Upload with VVV DE message: Buzzer plays the Morse. WPM set to 20: Faster code. WPM set to 5: Slow practice code.
Buzzer plays a steady tone: what should I check?
A passive buzzer needs tone(), check D9 and that noTone is called.
No keying on the optocoupler: what should I check?
Check the LED side polarity and the 330 Ω resistor.
Letters run together: what should I check?
Check the 2-dot delay after each letter.
Radio never keys: what should I check?
Check the key jack polarity and that the radio uses a simple closing-to-ground key line.
