//start // struct t_mtab { char c, pat; } ; struct t_mtab morsetab[] = { {'.', 106}, {',', 115}, {'?', 76}, {'/', 41}, {'A', 6}, {'B', 17}, {'C', 21}, {'D', 9}, {'E', 2}, {'F', 20}, {'G', 11}, {'H', 16}, {'I', 4}, {'J', 30}, {'K', 13}, {'L', 18}, {'M', 7}, {'N', 5}, {'O', 15}, {'P', 22}, {'Q', 27}, {'R', 10}, {'S', 8}, {'T', 3}, {'U', 12}, {'V', 24}, {'W', 14}, {'X', 25}, {'Y', 29}, {'Z', 19}, {'1', 62}, {'2', 60}, {'3', 56}, {'4', 48}, {'5', 32}, {'6', 33}, {'7', 35}, {'8', 39}, {'9', 47}, {'0', 63} } ; #define N_MORSE (sizeof(morsetab)/sizeof(morsetab[0])) #define SPEED (15) // CW WPM Keying speed set here #define DOTLEN (1200/SPEED) // Dit duration in ms #define DASHLEN (3*(1200/SPEED))// Dash duration in ms int LEDpin = 13 ; // Output pin for CW Out. //Function to Send a Dash at the Set CW speed void dash() { digitalWrite(LEDpin, HIGH) ; delay(DASHLEN); digitalWrite(LEDpin, LOW) ; delay(DOTLEN) ; } //******************************************************** //Function to Send a Dit at the Set CW speed void dit() { digitalWrite(LEDpin, HIGH) ; delay(DOTLEN); digitalWrite(LEDpin, LOW) ; delay(DOTLEN); } //******************************************************** // Function to convert a Character to Morse code and send // the on/off keying action to the output pin 13. void send(char c) { int i ; if (c == ' ') { // Space delay delay(7*DOTLEN) ; return ; } //loop for each part of the Character for (i=0; i