Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an SOS blinker sketch using morse code by lighting up the Arduino Uno\'s i

ID: 3869991 • Letter: W

Question

Write an SOS blinker sketch using morse code by lighting up the Arduino Uno's in board led pin. You must write the sketch without using the function delay(). Delay() prevents all other operations from running while it is waiting for the specified time to elapse. Instead, you can acquire the time since your code started running (in milliseconds) with millis() . By comparing the current time to a time previously collected, you can decide when to blink the LED. In morse cod, s is three dots and o is three dashes.

Explanation / Answer

Solution=================

In morse code,

Code======== Tested on Arduino Uno===================

int ledPin = 13;   //Default LED
int dot=100;      //Dot blink length
int dash=800;     //Dash Blink length

// The setup() method runs once, when the sketch starts

void setup()   {             
pinMode(ledPin, OUTPUT);
}

//Will blink for the specified speed
void writeMorse(int speed) {
digitalWrite(ledPin, HIGH);
delay(speed);
digitalWrite(ledPin, LOW);
delay(300);
}

//A user created delay method, using millis, as specified
void delayMillis(int time){
long calc= millis();
while(millis()-calc <3000);
}

void loop()                  
{

//Three dots for S
for (int x = 1; x <= 3; x++) {
    writeMorse(dot);
}

//End of letter
delayMillis(3000);


//Three dashes for O
for (int x = 1; x <= 3; x++) {
    writeMorse(dash);
}

//End of letter
delayMillis(3000);


//Three dots for S
for (int x = 1; x <= 3; x++) {
    writeMorse(dot);
}

//End of letter
delayMillis(3000);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote