main.cpp :
/*
* Morse Code
* Turns on the internal LED based on the morse code schema,
* https://en.wikipedia.org/wiki/Morse_code
* then off for one second, repeatedly.
*/
#include "Arduino.h"
void l()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(500);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(200);
}
void s()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(200);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(200);
}
void w()
{
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(1000);
}
void morseTranslator(char c)
{
if (c == 'a' || c == 'A') {s();l();}
if (c == 'b' || c == 'B') {l();s();s();s();}
if (c == 'c' || c == 'C') {l();s();l();s();}
if (c == 'd' || c == 'D') {l();s();s();}
if (c == 'e' || c == 'E') {s();}
if (c == 'f' || c == 'F') {s();s();l();s();}
if (c == 'g' || c == 'G') {l();l();s();}
if (c == 'h' || c == 'H') {s();s();s();s();}
if (c == 'i' || c == 'I') {s();s();}
if (c == 'j' || c == 'J') {s();l();l();l();}
if (c == 'k' || c == 'K') {l();s();l();}
if (c == 'l' || c == 'L') {s();l();s();s();}
if (c == 'm' || c == 'M') {l();l();}
if (c == 'n' || c == 'N') {l();s();}
if (c == 'o' || c == 'O') {l();l();l();}
if (c == 'p' || c == 'P') {s();l();l();s();}
if (c == 'q' || c == 'Q') {l();l();s();l();}
if (c == 'r' || c == 'R') {s();l();s();}
if (c == 's' || c == 'S') {s();s();s();}
if (c == 't' || c == 'T') {l();}
if (c == 'u' || c == 'U') {s();s();l();}
if (c == 'v' || c == 'V') {s();s();s();l();}
if (c == 'w' || c == 'W') {s();l();l();}
if (c == 'x' || c == 'X') {l();s();s();l();}
if (c == 'y' || c == 'Y') {l();s();s();l();l();}
if (c == 'z' || c == 'Z') {l();l();s();s();}
w();
//l();l();l();w(); s(); s(); s(); w(); l(); l();l();w();
}
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
morseTranslator('s');
morseTranslator('o');
morseTranslator('s');
w();
}
