Arduino project # 2. SOS signal
Arduino. Blinking LED

Arduino project # 2. SOS signal

Hi all! I today’s tutorial we are going to make a project with blinking LED which purpose will be to send SOS signal. The circuit will be the same as in previous project # 1 (“Blinking LED”). All we need to do is to change code of the project.

So, start point of this project is code of project # 1 (“Blinking LED”):

void setup() {
// initialize digital pin # 10 as an output.
// this is necessary part of every Arduino project

pinMode(10, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(10, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

For changing this code we need to add some variables. For SOS signal (and for all Morse code) let’s add three variables:

// long sound. Let's say it will be one second (1000 miliseconds)

int long_sound = 1000; 

int short_sound  = 200;

int short_pause = 500; // between sounds

int long_pause = 1000; // between letters

For SOS we need to make three long signals, three short signals and again three long signals. So, code can be next:

// the loop function runs over and over again forever
void loop() {

// "S" letter
digitalWrite(10, HIGH);
delay(long_sound);
digitalWrite(10, LOW);
delay(short_pause);
digitalWrite(10, HIGH);
delay(long_sound);
digitalWrite(10, LOW);
delay(short_pause);
digitalWrite(10, HIGH);
delay(long_sound);
digitalWrite(10, LOW);
delay(short_pause);

// pause between letters
delay(long_pause);

// "O" letter
digitalWrite(10, HIGH);

delay(short_sound); 

digitalWrite(10, LOW);
delay(short_pause);

digitalWrite(10, HIGH);
delay(short_sound);

digitalWrite(10, LOW);

delay(short_pause);

digitalWrite(10, HIGH);
delay(short_sound); 

digitalWrite(10, LOW);
delay(short_pause);

// pause between letters
delay(long_pause);

// "S" letter
digitalWrite(10, HIGH);

delay(long_sound); 

digitalWrite(10, LOW);
delay(short_pause);

digitalWrite(10, HIGH);
delay(long_sound);

digitalWrite(10, LOW);

delay(short_pause);

digitalWrite(10, HIGH);
delay(long_sound); 

digitalWrite(10, LOW);
delay(short_pause);

// pause between letters (for next phrases)
delay(long_pause);

}

That’s it! It works.

And video of result:

Sincerely your Positive Knight 🙂

Leave a Reply