{"id":1010,"date":"2014-12-30T14:22:52","date_gmt":"2014-12-30T13:22:52","guid":{"rendered":"http:\/\/www.pa3hcm.nl\/?p=1010"},"modified":"2021-01-18T17:12:41","modified_gmt":"2021-01-18T16:12:41","slug":"build-your-own-arduino-morse-keyer","status":"publish","type":"post","link":"https:\/\/www.pa3hcm.nl\/?p=1010","title":{"rendered":"Getting started with Arduino: morse keyer"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115736.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"225\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115736-300x225.jpg\" alt=\"[Image]\" class=\"wp-image-1019\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115736-300x225.jpg 300w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115736-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption>Close-up of the prototype keyer.<\/figcaption><\/figure><\/div>\n\n\n\n<p>Using a paddle to operate in morse code is very convenient. But paddles don&#8217;t create dots and dashes on their own, so you need some electronics, called a &#8220;keyer&#8221;. You may use the build-in keyer of your radio, but most of them lack of functionality. You may buy a keyer at your local ham store, but these are rather expensive. So why not build your own keyer? It&#8217;s fun to do, and you learn new things. The Arduino prototyping board allows you to build the most advanced and personalized keyer that you have in mind! This article gives you a decent start for such a keyer, by implementing the basic functionality and learn a bit about the Arduino platform if you&#8217;re not familiar with this board yet.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">About the Arduino<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_100957.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"225\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_100957-300x225.jpg\" alt=\"[Image]\" class=\"wp-image-1020\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_100957-300x225.jpg 300w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_100957-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption>The Arduino prototype board, this is the &#8220;Uno&#8221; version. Throughout the years several versions have been released, but all are code and pin compatible.<\/figcaption><\/figure><\/div>\n\n\n\n<p>The Arduino is one of the easiest prototyping platforms available nowadays. You can easily attach buttons, sensors, lights, displays, relays and motors and control them all with a simple program. You write the program using the <a href=\"http:\/\/arduino.cc\/en\/Main\/Software\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino IDE software<\/a> (available for Linux, Windows and Mac) and transfer it to your Arduino board using a USB-cable. Arduino boards are sold at most electronics shops and will cost about 20-25 euros \/ 25-30 USD. You may consider buying a starter kit, containing an Arduino board, a breadboard, and handful of parts (LED&#8217;s, switches, sensors, motor, servo, etc), wires, and&nbsp; a guide learning you the basics. Visit the <a href=\"http:\/\/www.arduino.cc\/\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino website<\/a> for more information.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">About paddles<\/h2>\n\n\n\n<p>Paddles come in different shapes and sizes. The keyer discussed in this article is meant for &#8220;twin paddles&#8221; or &#8220;iambic paddles&#8221;. Such a paddle has 2 levers, one for sending dots and one for the dashes. The &#8220;iambic&#8221; means that, when squeezing both levers, the keyer will translate this to a repetitive series of dot-dash-dot-dash-dot-dash-etc&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_124225.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_124225-1024x512.jpg\" alt=\"[Image]\" class=\"wp-image-1021\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_124225-1024x512.jpg 1024w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_124225-300x150.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Two examples of a paddle: the high-end Begali &#8220;Pearl&#8221; and the more common Bencher &#8220;BY-1&#8221;.<\/figcaption><\/figure>\n\n\n\n<p>Actually, if you look at your paddle, it&#8217;s just a double switch. Ok, it&#8217;s probably the most expensive and specialized switch in your home, but still it&#8217;s a switch. Each contact is shortened to a common contact, normally connected to &#8220;ground&#8221;. The other ends of the switches are connected to the &#8220;dot&#8221; and &#8220;dash&#8221; inputs of your keyer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The keyer hardware<\/h2>\n\n\n\n<p>It&#8217;s time to build the circuit. I suggest that you first build your prototype on a breadboard, at least I did for this article.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_131312.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_131312-1024x768.jpg\" alt=\"[Image]\" class=\"wp-image-1024\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_131312-1024x768.jpg 1024w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_131312-300x225.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>The complete circuit, less then 10 components!<\/figcaption><\/figure>\n\n\n\n<p>The main component of the keyer is (of course) the Arduino board, and we will create the following inputs and outputs:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>2 Digital inputs for the paddle (dot and dash contact).<\/li><li>1 Digital output to the key jack of your transmitter.<\/li><li>1 Digital output to sound a sidetone buzzer.<\/li><li>1 Analog input to read the speed from a potmeter.<\/li><\/ul>\n\n\n\n<p>Down here I&#8217;ll discuss these.<\/p>\n\n\n\n<p>The paddle contacts have to be translated to a digital &#8220;1&#8221; or &#8220;0&#8221;. Most paddles pull connect the contacts to ground, so when a lever is pressed it is a digital &#8220;0&#8221;. So when not pressed, a &#8220;1&#8221; should appear at the Arduino&#8217;s input, so we add a 10k pull-up resistor to each contact, connecting it to +5V (operating voltage of the Arduino). The contacts can now be connected to the Arduino, using the digital I\/O pins labelled &#8220;D2&#8221; and &#8220;D3&#8221;. The arduino also provides pins labelled &#8220;GND&#8221; (for the ground connection of the keyer) and &#8220;5V&#8221; (for the pull-up resistors).<\/p>\n\n\n\n<p>The software processes the inputs from the keyer and produces the dots and dashes. Therefore it keys pin &#8220;D13&#8221;. When high (+5V), the key is pressed. We attach a transistor (almost any common NPN type transistor will do) to this pin. When ping D13 is high, the transistor pulls the key input of the connected transmitter to ground, as if a straight key was connected.<\/p>\n\n\n\n<p>During key down, the software will generate a square wave on pin &#8220;D12&#8221;, allowing you to attach a small buzzer. You could also shape the signal a bit using an RC circuit and feed a LM386 based audio amplifier, allowing you to attach a small speaker or headphones, but I&#8217;ll leave that to you. For now, the buzzer will be fine.<\/p>\n\n\n\n<p>You definitely want to be able to set the keying speed, so therefore we will attach a potmeter. The center pin will be connected to analog input &#8220;A0&#8221; of the Arduino, while the other 2 pins are connected to GND and 5V.<\/p>\n\n\n\n<figure class=\"wp-block-gallery columns-3 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115821-e1419941944283.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115821-e1419941944283.jpg\" alt=\"[Image]\" data-id=\"1025\" class=\"wp-image-1025\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115821-e1419941944283.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115821-e1419941944283-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115821-e1419941944283-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115853-e1419942445619.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115853-e1419942445619.jpg\" alt=\"[Image]\" data-id=\"1026\" class=\"wp-image-1026\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115853-e1419942445619.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115853-e1419942445619-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_115853-e1419942445619-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120105-e1419942478797.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120105-e1419942478797.jpg\" alt=\"[Image]\" data-id=\"1027\" class=\"wp-image-1027\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120105-e1419942478797.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120105-e1419942478797-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120105-e1419942478797-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120307-e1419942466108.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120307-e1419942466108.jpg\" alt=\"[Image]\" data-id=\"1028\" class=\"wp-image-1028\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120307-e1419942466108.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120307-e1419942466108-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_120307-e1419942466108-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121002-e1419942455759.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121002-e1419942455759.jpg\" alt=\"[Image]\" data-id=\"1029\" class=\"wp-image-1029\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121002-e1419942455759.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121002-e1419942455759-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121002-e1419942455759-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121039-e1419942434864.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121039-e1419942434864.jpg\" alt=\"[Image]\" data-id=\"1030\" class=\"wp-image-1030\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121039-e1419942434864.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121039-e1419942434864-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121039-e1419942434864-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121232-e1419942422202.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121232-e1419942422202.jpg\" alt=\"[Image]\" data-id=\"1031\" class=\"wp-image-1031\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121232-e1419942422202.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121232-e1419942422202-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121232-e1419942422202-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121259-e1419942409282.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121259-e1419942409282.jpg\" alt=\"[Image]\" data-id=\"1032\" class=\"wp-image-1032\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121259-e1419942409282.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121259-e1419942409282-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121259-e1419942409282-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121419-e1419942396799.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"2560\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121419-e1419942396799.jpg\" alt=\"[Image]\" data-id=\"1033\" class=\"wp-image-1033\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121419-e1419942396799.jpg 1920w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121419-e1419942396799-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121419-e1419942396799-768x1024.jpg 768w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure><\/li><\/ul><\/figure>\n\n\n\n<p>The hardware is finished now, so let&#8217;s go on to the software part.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The keyer software<\/h2>\n\n\n\n<p>Once installed the Arduino IDE software, you can simply start it and begin typing your code. You can <a href=\"https:\/\/github.com\/pa3hcm\/simple_iambic_keyer\/blob\/master\/simple_iambic_keyer.ino\" target=\"_blank\" rel=\"noopener noreferrer\">download<\/a> the keyer code from my <a href=\"https:\/\/github.com\/pa3hcm\/simple_iambic_keyer\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub repository<\/a> to save you some time. If you have never programmed an Arduino before, you might first take a look at some examples, starting with this one: File \u2192 Examples \u2192 Basics \u2192 Blink. In the text down here I have added links to the online Arduino Language Reference.<\/p>\n\n\n\n<p>Let&#8217;s start coding. The keyer software consists of 4 parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Declarations.<\/li><li>The &#8220;setup&#8221; function.<\/li><li>The main routine, called &#8220;loop&#8221;.<\/li><li>The custom &#8220;keyAndBeep&#8221; function.<\/li><\/ul>\n\n\n\n<p>We start with the declarations. We <a href=\"http:\/\/arduino.cc\/en\/Reference\/Define\" target=\"_blank\" rel=\"noopener noreferrer\">define<\/a> constants for all pins used, and also introduce a variable (<a href=\"http:\/\/arduino.cc\/en\/Reference\/Int\" target=\"_blank\" rel=\"noopener noreferrer\">integer<\/a>) to store the value of the potmeter, called &#8220;speed&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#define P_DOT&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp; \/\/ Connects to the dot lever of the paddle\n#define P_DASH&nbsp;&nbsp; 3&nbsp;&nbsp; \/\/ Connects to the dash lever of the paddle\n#define P_AUDIO 12&nbsp;&nbsp; \/\/ Audio output\n#define P_CW&nbsp;&nbsp;&nbsp; 13&nbsp;&nbsp; \/\/ Output of the keyer, connect to your radio\n#define P_SPEED A0&nbsp;&nbsp; \/\/ Attached to center pin of potmeter, allows you\n                     \/\/ to set the keying speed.\n\nint speed;<\/pre>\n\n\n\n<p>The next step is the <a href=\"http:\/\/arduino.cc\/en\/Reference\/Setup\" target=\"_blank\" rel=\"noopener noreferrer\">setup<\/a> routine. The Arduino runs this code only once, at start\/boot time. We use this to define which pin is an input or an output, using the <a href=\"http:\/\/arduino.cc\/en\/Reference\/PinMode\" target=\"_blank\" rel=\"noopener noreferrer\">pinMode<\/a> statement. We also ensure that there is no key output, by setting the output pin to LOW using the <a href=\"http:\/\/arduino.cc\/en\/Reference\/DigitalWrite\" target=\"_blank\" rel=\"noopener noreferrer\">digitalWrite<\/a> statement:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Initializing the Arduino\nvoid setup()\n{\n&nbsp; pinMode(P_DOT, INPUT);\n&nbsp; pinMode(P_DASH, INPUT); \n&nbsp; pinMode(P_AUDIO, OUTPUT);\n&nbsp; pinMode(P_CW, OUTPUT);\n&nbsp; digitalWrite(P_CW, LOW);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Start with key up\n}<\/pre>\n\n\n\n<p>Notice that we used the contants we just declared, not the pin numbers itself.<\/p>\n\n\n\n<p>Let&#8217;s go on to the main routine, called <a href=\"http:\/\/arduino.cc\/en\/Reference\/Loop\" target=\"_blank\" rel=\"noopener noreferrer\">loop<\/a>. This one repeats itself continuously, so when the last statement is executed, it returns to the start of this loop again. The first statement reads the value of the potmeter using the <a href=\"http:\/\/arduino.cc\/en\/Reference\/AnalogRead\" target=\"_blank\" rel=\"noopener noreferrer\">analogRead<\/a> statement, and stores it in our &#8220;speed&#8221; variable. Next it reads the input pin connected to the &#8220;dot&#8221; contact of the paddle using <a href=\"http:\/\/arduino.cc\/en\/Reference\/DigitalRead\" target=\"_blank\" rel=\"noopener noreferrer\">digitalRead<\/a>. <a href=\"http:\/\/arduino.cc\/en\/Reference\/If\" target=\"_blank\" rel=\"noopener noreferrer\">If<\/a> the input is low, it calls a custom function called &#8220;keyAndBeep&#8221;, which we will discuss in a moment. Then there&#8217;s a short <a href=\"http:\/\/arduino.cc\/en\/Reference\/Delay\" target=\"_blank\" rel=\"noopener noreferrer\">delay<\/a>, since we want a bit of time after sending a dot. If we would skip this delay, there would be no separation between succeeding dots and\/or dashes. Finally, we do the same for the &#8220;dash&#8221; contact, but now the key has to be down 3x longer, hence the &#8220;speed*3&#8221; argument. Now the routine returns to the first statement, reading the value of the potmeter again, checking the dot lever, etc&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Main routine\nvoid loop()\n{\n&nbsp; speed = analogRead(P_SPEED)\/2; \/\/ Read the keying speed from potmeter\n&nbsp; if(!digitalRead(P_DOT))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ If the dot lever is presssed..\n&nbsp; {\n&nbsp;&nbsp;&nbsp; keyAndBeep(speed);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ ... send a dot at the given speed\n&nbsp;&nbsp;&nbsp; delay(speed);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/&nbsp;&nbsp;&nbsp;&nbsp; and wait before sending next\n&nbsp; }\n&nbsp; if(!digitalRead(P_DASH))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ If the dash lever is pressed...\n&nbsp; {\n&nbsp;&nbsp;&nbsp; keyAndBeep(speed*3);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ ... send a dash at the given speed\n&nbsp;&nbsp;&nbsp; delay(speed);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/&nbsp;&nbsp;&nbsp;&nbsp; and wait before sending next\n&nbsp; }\n}<\/pre>\n\n\n\n<p>The final part of the code does the actual keying and sounding. We call this function &#8220;keyAndBeep&#8221;. It starts with keying the output, setting the P_CW pin to &#8220;HIGH&#8221; (5V). This will drive the transistor to key the transmitter. Then a <a href=\"http:\/\/arduino.cc\/en\/Reference\/For\" target=\"_blank\" rel=\"noopener noreferrer\">for<\/a> loop runs for a while, all statements within this loop are repeated lots of times, depending on the value of the &#8220;speed&#8221; variable (so the setting of the potmeter). Each iteration the audio output is set to HIGH, then we wait 1 millisecond, and then set the output to LOW again and wait another millisecond. This results in a square wave of about 500 Hz (roughly). When the loop is ended, the key output is set to &#8220;LOW&#8221; again and the connected transmitter will stop.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Key the transmitter and sound a beep\nvoid keyAndBeep(int speed)\n{\n&nbsp; digitalWrite(P_CW, HIGH);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Key down\n&nbsp; for (int i=0; i &lt; (speed\/2); i++)&nbsp;&nbsp;&nbsp; \/\/ Beep loop\n&nbsp; {\n&nbsp;&nbsp;&nbsp; digitalWrite(P_AUDIO, HIGH);\n&nbsp;&nbsp;&nbsp; delay(1);\n&nbsp;&nbsp;&nbsp; digitalWrite(P_AUDIO, LOW);\n&nbsp;&nbsp;&nbsp; delay(1);\n&nbsp; }\n&nbsp; digitalWrite(P_CW, LOW);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Key up\n}<\/pre>\n\n\n\n<p>In case you missed it&#8230; you can download the complete code here: <a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/pa3hcm_simple_iambic_keyer.txt\">pa3hcm_simple_iambic_keyer.txt<\/a><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121540-e1419942386921.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"225\" height=\"300\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121540-e1419942386921-225x300.jpg\" alt=\"[Image]\" class=\"wp-image-1034\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121540-e1419942386921-225x300.jpg 225w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121540-e1419942386921-768x1024.jpg 768w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_121540-e1419942386921.jpg 1920w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><figcaption>Connect the Arduino board to your PC using a standard USB A-B cable. Then upload the code using the Arduino IDE software.<\/figcaption><\/figure><\/div>\n\n\n\n<p>Now connect the Arduino to your PC and upload the code. Once uploaded the keyer will come to live immediately, since it&#8217;s powered by USB now. You can simply remove the USB cable now and power the Arduino by attaching a 9V battery or a 9-15 volts DC adapter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Next steps<\/h2>\n\n\n\n<p>Congratulations, You&#8217;ve just finished the prototype of your keyer! But this is just a very basic keyer. Here are some ideas to extend\/personalize your keyer:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Add one ore more buttons (use pull-up resistors, like done with the paddle buttons) to transmit standard texts, like your callsign or a CQ message.<\/li><li>Add an LCD display showing the current speed. It&#8217;s easier than you think! For an example just go to the menu of the Arduino IDE software and click: File \u2192 Examples \u2192 LiquidCrystal \u2192 HelloWorld.<\/li><li>Create a memory keyer, the Arduino has an internal EEPROM where you can store your messages.<\/li><li>Replace the buzzer by a lowpass filter (to shape the square wave) and a LM386 based audio amplifier, so you can use a small speaker (sounds nicer) and\/or headphones.<\/li><li>Place a small capacitor (10nF) between each input\/output and ground to prevent RF interference.<\/li><li>Take a look at other Arduino-based keyers on the web and get inspired.<\/li><li>Add an Ethernet Shield to the Arduino and enable keying over your local network.<\/li><li>Add a Bluetooth Shield to the Arduino, and create an app to control the keyer using your mobile phone.<\/li><li>Build a very small keyer using the Arduino Mini, Micro or Nano.<\/li><li>Build your final version in a fancy enclosure!<\/li><\/ul>\n\n\n\n<p>As always&#8230; for any questions or comments regarding this article just place a comment down here, or use the contact form on this website to send me a private email.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_122158.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_122158-1024x768.jpg\" alt=\"[Image]\" class=\"wp-image-1035\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_122158-1024x768.jpg 1024w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/20141230_122158-300x225.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Completed prototype of the Arduino morse code keyer.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What others did<\/h2>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/IMG_7035.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"645\" src=\"http:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/IMG_7035-1024x645.jpg\" alt=\"[Image]\" class=\"wp-image-1209\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/IMG_7035-1024x645.jpg 1024w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2014\/12\/IMG_7035-300x189.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Bill W7WEL built the keyer on copper clad, therefore he removed the microcontroller chip from the Arduino board, placed it in a socket, and added a clock circuit and power to get the chip running.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Home made touch sensitive Morse (CW) Paddle\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/blETE3PYND4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Chris ZS1CDG built a slightly different version, which is a touch paddle. He replaced both 10k resistors with 2M ones and uses his fingers as &#8220;switches&#8221;. He showed the result in this nice video.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Video 3\" width=\"1290\" height=\"968\" src=\"https:\/\/www.youtube.com\/embed\/d9GSd0PqIdg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Tommy NE5TH built it using a breadboard shield.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Morse Trainer\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/S1sW7xs_xzQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Maks UT3UEZ used it in a morse trainer\/simulator, using an Arduino Mini. He uses a second Arduino Mini to decode the signal again and show the result on a display.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Very simple Arduino CW keyer for an hour\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/J-2DsarAEOA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Yuri EW6BN put his version into a small plastic mints box.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"CW keyer shield for WeMOS TTGO Xi Ocrobot Alpha 8F328P-U\" width=\"1290\" height=\"968\" src=\"https:\/\/www.youtube.com\/embed\/cFADTW8faSA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Based on this article, Daniel VE7LCG built this very small keyer, including a tiny paddle!<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Morse code practice using a DIY iambic keyer (DU1AU)\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/n-Kl5EzFmXQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Anthony DU1AU build this neat integrated keyer.<\/p>\n\n\n\n<p>More builders:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/f0dcl.blogspot.nl\/2016\/12\/arduino-uno_17.html\" target=\"_blank\" rel=\"noopener noreferrer\">F0DCL<\/a><\/li><li><a href=\"https:\/\/www.rogerk.net\/forum\/index.php?topic=69229.0\" target=\"_blank\" rel=\"noopener noreferrer\">IW2JAF<\/a><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>This article was also published in:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/downloads.dkars.nl\/DKARS%20Magazine%20201502.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">DKARS Magazine, February 2015<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Using a paddle to operate in morse code is very convenient. But paddles don&#8217;t create dots and dashes on their own, so you need some electronics, called a &#8220;keyer&#8221;. You may use the build-in keyer of your radio, but most of them lack of functionality. You may buy a keyer at your local ham store, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1019,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63],"tags":[47,27,28,84],"class_list":["post-1010","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tools-and-measurement","tag-arduino","tag-beginners","tag-cw","tag-paddle"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/1010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1010"}],"version-history":[{"count":27,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/1010\/revisions"}],"predecessor-version":[{"id":1885,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/1010\/revisions\/1885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/media\/1019"}],"wp:attachment":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}