2.1 – Arduino SOS

In our first 2 projects we have demonstrated that we can cause the Arduino to perform operations, specifically turning an LED on and off. Now let’s have the LED communicate a message for us, specifically SOS. In morse code S is defined as … or dot dot dot. O is defined as — or dash dash dash. We’ll refer to each dot as a dit and each dash as a dah.

In terms of the LED blinking, a dit would be a short on-off cycle, a dah will be a long on-off cycle. The dot duration is the basic unit of time measurement in Morse code transmission. The duration of a dash is three times the duration of a dot. Each dot or dash within a character is followed by a period of signal absence, called a space, equal to the dot duration.

For our project, we will make our dits 250 milliseconds. How long should our dahs be?

/*
NAME
SOS
Engineering Period 1
DATE

Revision History
DATE  |    NAME    |     Changes Made
------|------------|------------------------------
TODAY |  My Name   |  Initial Implementation

*/

void setup() {
  // put your setup code here, to run once:
  //pin 13 is the built in LED
  pinMode (13, OUTPUT);

}

void loop() {

  //Send an S
  
  //DIT Start
  digitalWrite(13,HIGH);
  delay(250);
  digitalWrite(13, LOW);
  delay(250);
  //DIT END

  //DIT Start
  digitalWrite(13,HIGH);
  delay(250);
  digitalWrite(13, LOW);
  delay(250);
  //DIT END

  //DIT Start
  digitalWrite(13,HIGH);
  delay(250);
  digitalWrite(13, LOW);
  delay(250);
  //DIT END

  //End of the S lets Pause to separate our letters
  delay(500);

  //Send the Letter O
    
  //DAH Start
  digitalWrite(13,HIGH);
  delay(750);
  digitalWrite(13, LOW);
  delay(250);
  //DAH END

  //DAH Start
  digitalWrite(13,HIGH);
  delay(750);
  digitalWrite(13, LOW);
  delay(250);
  //DAH END

  //DAH Start
  digitalWrite(13,HIGH);
  delay(750);
  digitalWrite(13, LOW);
  delay(250);
  //DAH END

  //End of the O - Another pause to separate letters
  delay(500);

  //Send the S Again...

    //DIT Start
  digitalWrite(13,HIGH);
  delay(250);
  digitalWrite(13, LOW);
  delay(250);
  //DIT END

  //DIT Start
  digitalWrite(13,HIGH);
  delay(250);
  digitalWrite(13, LOW);
  delay(250);
  //DIT END

  //DIT Start
  digitalWrite(13,HIGH);
  delay(250);
  digitalWrite(13, LOW);
  delay(250);
  //DIT END

  //End of the message  pause before repeating the message or next word
  //Note this pause is a little longer than between letters.
  delay(1250);
  

}