int wpm = 15; // Words per minute CW speed float ditf = 1200/wpm; // dit length in ms is 1200/WPM according to Wiki int dit = ditf; // convert the floating point maths to an integer so we can use the delay function int dah = 3 * dit; // hah is 3 dits int lspace = dah; // letter space is the same as a dah int cspace = dit; // character space is the same as a dit int wspace = 7 * dit; // word space is 7 dits int cw_key_line = 2; // use digital output pin 2 fopr the CW key line void setup() { // put your setup code here, to run once: pinMode (cw_key_line, OUTPUT); // set the key line to be an output digitalWrite (cw_key_line, HIGH); // default it to HIGH which is key up } void beacon() { digitalWrite (cw_key_line, LOW); // set key down for 4000 ms (4s) delay(4000); digitalWrite (cw_key_line, HIGH); } void char_space() // character space { delay (cspace); } void dot () // key down for the dot duration { digitalWrite(cw_key_line, LOW); delay(dit); digitalWrite(cw_key_line, HIGH); char_space(); } void dash () // key down for the dash duration { digitalWrite(cw_key_line, LOW); delay(dah); digitalWrite(cw_key_line, HIGH); char_space(); } void word_space () // word space { delay (wspace); } void letter_space () // letter space { delay(lspace); } void char_0 () // you will get the idea now..... { dash(); dash(); dash(); dash(); dash(); letter_space(); } void char_9 () { dash(); dash(); dash(); dash(); dot(); letter_space(); } void char_3 () { dot(); dot(); dot(); dash(); dash(); letter_space(); } void char_a () { dot(); dash(); letter_space(); } void char_g () { dash(); dash(); dot(); letter_space(); } void char_i () { dot(); dot(); letter_space(); } void char_m () { dash(); dash(); letter_space(); } void char_o () { dash(); dash(); dash(); letter_space(); } void char_x () { dash(); dot(); dot(); dash(); letter_space(); } void g0mgx () { char_g(); char_0(); char_m(); char_g(); char_x(); } void io93ga () { char_i(); char_o(); char_9(); char_3(); char_g(); char_a(); } void loop() { // put your main code here, to run repeatedly: g0mgx(); word_space(); io93ga(); word_space(); beacon(); word_space(); }