int t = 150; // one unit of time in milliseconds void setup() { pinMode(13, OUTPUT); // LED pin is OUTPUT } void dot() { digitalWrite(13, HIGH); delay(1*t); digitalWrite(13, LOW); delay(1*t); } void dash() { digitalWrite(13, HIGH); delay(3*t); digitalWrite(13, LOW); delay(1*t); } void letter() { delay(2*t); // plus one unit from end of dot/dash = 3 units } void word() { delay(6*t); // plus one unit from end of dot/dash = 7 units } // Scan PATTERN and send a dot for every '.' or a dash for every '-'. // Any other character generates an inter-letter pause. // Generate an inter-word pause at the end of the string. void sendMorse(char *pattern) { int i = 0; // index into string while (0 != pattern[i]) { int c = pattern[i]; // current character if ('.' == c) dot(); else if ('-' == c) dash(); else letter(); i = i+1; } word(); } void loop() { sendMorse("... --- ..."); }