Arduino Projects

Arduino Morse Code Practice Oscillator

Morse code almost not need an explanation! Anyway simply note that it’s a telegraph code in which letters and numbers are represented by strings of dots and dashes (short and long signals). Arduino Morse Code Practice Oscillator-Proto(1)Learning and practicing the Morse code obviously requires a little code practice oscillator (CPO) to work with the Morse key. Luckily you can find a simple do it yourself project idea based on discrete components elsewhere in this Codrey website.

For a while now, I’ve had need of making a portable code practice oscillator, for my friendly neighbor, to be able to practice Morse code. Also, I have been asked by him several times for a quick design utilizing the Arduino microcontroller platform. To this end, I had got a good idea and eventually built an Arduino Morse Code Practice Oscillator that runs happily on a standard 6F22/PP3 9V battery. With this article, I try to share details of my little code practice oscillator project to you. I am happy if you got inspiration from the project idea presented here or learned something new.

Apart from an Arduino Uno board, only one Morse Key (telegraph key), and a little bit of supporting electronics is all that needed to complete the project. The extra electronics circuitry is nothing but a single transistor based loud speaker driver. See its circuit diagram below:

Arduino Morse Code Practice Oscillator -External Circuit

Many Arduino projects have an idea that uses the Arduino function tone() to generate a sound. Typically a small loudspeaker is connected to an Arduino pin, either by a resistor or a coupling capacitor. While that idea works well for demonstrations, the use of a resistor or capacitor alone has certain disadvantages including low-volume tone output. A linear audio amplifier can make it louder, but at the expense of respective parts.

When you’re hooking up a loudspeaker to an Arduino as mentioned above, the reason for the feeble sound comes down to the fact that the digital out pins on AVR microcontrollers can only source (or sink) around 50mA. Most loudspeakers, including the small ones, might draw a lot more current than that, and without an ‘active’ circuitry in between you’d probably fry the pin on your microcontroller!

Note that the Arduino tone is merely a square wave repeated at the desired frequency, and it’s not very musical. So to make the tone output louder all that’s needed is a way to increase current through the loud speaker. And this can be done by the given extra electronics circuitry. Notice the positive rail connection to Vin header rather than the 5V header. This allows greater current than can be delivered via the Arduino itself.

The Arduino Sketch is prepared out pretty much simple as the hardware. When you run it you should hear tones when you press the Morse Key. Copy and paste the given code on the right into your Arduino. The code start by declaring variables for the input and output pins. The ‘val’ will be where it stores the state of the key input. The ‘keyTone’ is the frequency of the tone you will hear.

Give this a try and see how it goes. It’s certainly something to bear in mind, the 440Hz created a much more sweet tone for me. You may need to experiment to find a value that works in your own constructs. Don’t forget, the Tone() function can generate only square waves of fixed 50% duty cycle. And, the frequency value should be of minimum 31HZ and 65.535kHZ maximum as it’s the minimum and maximum frequency values that can be produced by AVR boards.

/* 
Morse Code Oscillator v1
Another Simple, Adaptable, Arduino Project
Authored By T.K.Hareendran/2019
Published By www.codrey.com
*/

int morseKey=8; // Morse Key Input D8
int sounder=9; // Key Tone Output D9
int val=0; 
int keyTone=440; // Key Tone Frequency 440Hz 
void setup() {
pinMode(morseKey, INPUT);
pinMode(sounder,OUTPUT);
digitalWrite(morseKey,HIGH); // Weak Internal Pull-up Enabled
}
void loop() {
val=digitalRead(morseKey); 
if (val)  noTone(sounder);
if (!val) tone(sounder,keyTone);  
}

Here’s an oscilloscope picture of the ‘unloaded’ D9 output signal I’ve got with my code, worked excellent for me.

Arduino Morse Code Practice Oscillator-Scope D9 Open Probe

Following is a pair of casual snaps of my hardware lash-up:

Arduino Morse Code Practice Oscillator-Proto(1)

Arduino Morse Code Practice Oscillator-Proto(2)

Getting back to the loudspeaker driver circuitry, the driver transistor T1 will switch on and off the loudspeaker according to the square wave input. The amplitude of the signal appeared across the loud speaker depends heavily on the positive rail voltage VIN fed in at top. This setup does suffice to get you finally on the upbeat as square waves don’t really necessitate ‘harmonious’ amplification, do they?

I didn’t add a path for the inductive flyback current to go when the driver transistor abruptly shuts off. You don’t bother, at this fairly low power, and Notedly in this project, it might not going to fry the driver transistor.

Further, a noteworthy fact is that the major advantage of mylar speaker over the common paper speaker comes in applications where moisture or humidity are considerations. While paper tends to absorb moisture (affecting the mass of the cone with a resulting shift in resonance), mylar is relatively immune to this. An alias for mylar is polyethylene terephthalate (PET) which is used in the pedestrian water bottle. See https://www.stetron.com/loudspeakers-mylar-santoprene/

In conclusion I want to say, I find it can alleviate learning to review what you get over after you get a line on it. So just snap up requisite hardware and start building a portable code practice oscillator with your Arduino. I would love to hear about that in the comments. Let’s make some noise with Arduino!

Leave a Comment