Search This Blog

Monday, April 22, 2013

Arduino Morse Code Keyer/Oscillator

Recently I acquired my Ham Radio license and after upgrading from Technician to General class I decided to build a Morse Code oscillator/keyer. I started by building an Iambic paddle from Plexiglass PCboard pieces, some scrap wood, and screws. I will improve on the design as many factors are far from suitable. Here are a few photos of it and the basic design sketch of it.

The basic idea is that the pc board on the side touches the screw from the corresponding side depending on which side is pressed. That effectively short circuits the two wires together.
Now I tried experimenting with it a lot and I had problems with the If and While commands in the Arduino IDE but after a long time experimenting I finally found the idea that I could have it play two tones and then put those into the paddle so when I pressed the paddle the center wire will get the tone from one of the two wires. So I hooked up the center wire of the paddle to the speaker and voila! I now have a Morse code keyer and practice oscillator.
Now the Arduino can only generate one tone at a time, so to solve this I used the delay Microsecond command to rapidly switch between the two tones. The program generates a tone at () hertz on digital pin 9 then it pauses one microsecond and stops the tone. After that, it starts a tone at () hertz on digital pin 11 and delays one microsecond and it stops the tone then it repeats that. Using the powerful switching capability of the Arduino we can effectively produce two tones seemingly simultaneously. 
the code for this is listed below.

void setup(){
pinMode(9, OUTPUT);
pinMode(11, OUTPUT);

void loop(){
  tone(9, 121);
  noTone(9   0);
  tone(11, 4186);

If you have any questions feel free to contact me through the comments section of this blog post and I will get back to you as soon as I can.