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

Coding question for Arduino. In the lab assignment, you were required to make an

ID: 2079520 • Letter: C

Question

Coding question for Arduino.

In the lab assignment, you were required to make an LED blink and send a message over the serial port. For this assignment, you will be required to expand upon this by using the LED to communicate your initials using Morse Code (see description of Morse code below). Your initials should be three letters. For example, Jane Smith Doe would be JSD. If you make one time unit equal to half a second (500ms), then the Letter J would be created by turning the light on and off for the following sequence: On (500ms) [dot] Off (500ms) [inter-element gap] On (1500ms) [dash] Off (500ms) [inter-element gap] On (1500ms) [dash] Off (500ms) [inter-element gap] On (1500ms) [dash] Off (1500ms) (short gap) Start letter S ... International Morse code is composed of five elements: short mark, dot or "dit" (.) - "dot duration" is one time unit long longer mark, dash or "dah" (-) - three time units long inter-element gap between the dots and dashes within a character - one dot duration or one unit long short gap (between letters) - three time units long medium gap (between words) - seven time units long

Explanation / Answer

Program for communicating initials JSD

int utime=500; //defining one unit as 500ms

int ledPin=13; // defining led pin number on the board, taking example as 13

void dot()

{ digitalWrite(ledPin,HIGH);

delay(utime);

digitalWrite(ledPin,LOW);

delay(utime);

}

void dash()

{ digitalWrite(ledPin,HIGH);

delay(3*utime);

digitalWrite(ledPin,LOW);

delay(utime);

digitalWrite(ledPin,HIGH);

delay(3*utime);

digitalWrite(ledPin,LOW);

delay(utime);

digitalWrite(ledPin,HIGH);

delay(3*utime);

digitalWrite(ledPin,LOW);

delay(3*utime);

}

void dot() //for starting letter S

digitalWrite(ledPin,HIGH);

delay(utime);

digitalWrite(ledPin,LOW);

delay(utime);

digitalWrite(ledPin,HIGH);

delay(utime);

digitalWrite(ledPin,LOW);

delay(utime);

digitalWrite(ledPin,HIGH);

delay(utime);

digitalWrite(ledPin,LOW);

delay(3*utime); //for giving short gap betwen next letter

}

void dash()

{

digitalWrite(ledPin,HIGH);

delay(3*utime);

digitalWrite(ledPin,LOW);

delay(utime);

}

void dot()

digitalWrite(ledPin,HIGH);

delay(utime);

digitalWrite(ledPin,LOW);

delay(utime);

digitalWrite(ledPin,HIGH);

delay(utime);

digitalWrite(ledPin,LOW);

delay(utime);

}