/* Morse Code Fox Transmitter Sketch */ /* for Sonobuoy Fox Hunt Transmitter http://www.qsl.net/kp4md/sonobuoy.htm */ /* Original code by MH Atkinson http://www.multiwingspan.co.uk */ /* Loop code by K Hooke KK6DCT http://www.kevinhooke.com */ /* Look-up table completed by C Milazzo KP4MD http://www.qsl.net/kp4md */ const int buzzerPin = 9; const int ledPin = 13; const int tonefreq = 1200; //change to 2500 for louder piezo output // constants for tone and rest durations const int dotlength = 100; const int dashlength = dotlength * 3; // inter-element gap - between each dot or dash of a letter const int inter = dotlength; // letter gap is 3 dots - the inter gap is always added - so this is one fewer const int lgap = dotlength * 2; // inter-letter gap // word gap is 7 dots - with letter and inter gap already counted, this is -1 const int wgap = dotlength * 4; //inter-word gap const char message[] = "QTH? CAN YOU FIND ME? DE N6NA/FOX + "; //text must be in CAPITALS void setup() { //Serial.begin(9600); } void loop() { for(int currentLetterIndex; currentLetterIndex < sizeof(message); currentLetterIndex++){ char currentLetter = message[currentLetterIndex]; soundLetter(currentLetter); } } void soundLetter(char letter) { // Serial.print(letter); // letters are in alphabetic order, then numbers, then punctuation and prosigns switch(letter) { case 'A': dit();dah(); break; case 'B': dah();dit();dit();dit(); break; case 'C': dah();dit();dah();dit(); break; case 'D': dah();dit();dit(); break; case 'E': dit(); break; case 'F': dit();dit();dah();dit(); break; case 'G': dah();dah();dit(); break; case 'H': dit();dit();dit();dit(); break; case 'I': dit();dit(); break; case 'J': dit();dah();dah();dah(); break; case 'K': dah();dit();dah(); break; case 'L': dit();dah();dit();dit(); break; case 'M': dah();dah(); break; case 'N': dah();dit(); break; case 'O': dah();dah();dah(); break; case 'P': dit();dah();dah();dit(); break; case 'Q': dah();dah();dit();dah(); break; case 'R': dit();dah();dit(); break; case 'S': dit();dit();dit(); break; case 'T': dah(); break; case 'U': dit();dit();dah(); break; case 'V': dit();dit();dit();dah(); break; case 'W': dit();dah();dah(); break; case 'X': dah();dit();dit();dah(); break; case 'Y': dah();dit();dah();dah(); break; case 'Z': dah();dah();dit();dit(); break; case '1': dit();dah();dah();dah();dah(); break; case '2': dit();dit();dah();dah();dah(); break; case '3': dit();dit();dit();dah();dah(); break; case '4': dit();dit();dit();dit();dah(); break; case '5': dit();dit();dit();dit();dit(); break; case '6': dah();dit();dit();dit();dit(); break; case '7': dah();dah();dit();dit();dit(); break; case '8': dah();dah();dah();dit();dit(); break; case '9': dah();dah();dah();dah();dit(); break; case '0': dah();dah();dah();dah();dah(); break; case '.': dit();dah();dit();dah();dit();dah(); break; case '?': dit();dit();dah();dah();dit();dit(); break; case ',': dah();dah();dit();dit();dah();dah(); break; case '=': dah();dit();dit();dit();dah(); // = BT (double dash) prosign break; case '+': dit();dah();dit();dah();dit(); // + AR (end of message) prosign break; case '%': dit();dah();dit();dit();dit(); // % AS (wait) prosign break; case ')': dah();dit();dah();dah();dit(); // ) KN (go ahead, exclusive) prosign break; case '/': dah();dit();dit();dah();dit(); break; case ']': dit();dit();dit();dah();dit();dah(); // ] SK prosign break; case ' ': delay(wgap); break; } delay(lgap); } void dit() { // play a dot tone(buzzerPin, tonefreq); // LED on digitalWrite(ledPin, HIGH); delay(dotlength); noTone(buzzerPin); // LED off digitalWrite(ledPin, LOW); delay(inter); } void dah() { // play a dash tone(buzzerPin, tonefreq); // LED on digitalWrite(ledPin, HIGH); delay(dashlength); noTone(buzzerPin); // LED off digitalWrite(ledPin, LOW); delay(inter); }