Using the Arduino blink sketch below, implement the series of events by strobing
ID: 2080669 • Letter: U
Question
Using the Arduino blink sketch below, implement the series of events by strobing the internal LED with an SOS message. The letters are defined as: S = “. . . “ O = “- - -” S = “. . . “
Letter S is three short pulses followed by letter O which contains three long pulses. The timing sequence should be such that the “.” must be ON for 100ms followed by 100ms OFF between successive “.” pulses. The space between letters must be 500ms OFF. The “-” must be ON for 300ms followed by 100ms OFF between successive “-“ pulses.
The code sequence must be contained in the loop() function – remain in an infinite loop and DO NOT WRITE LINEAR CODE THAT SEQUENTIALLY PRINTS EACH LETTER ONLY ONCE IN THE MAIN LOOP. You must create a function for each letter.
Blink code:
int LED = 13;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(100);
digitalWrite(LED, LOW);
delay(3000);
}
Explanation / Answer
int led=13;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
blinks();
offled();
blinko();
offled();
blinks();
offled();
}
void blinks()
{
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
}
void blinko()
{
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(300);
}
void offled()
{
digitalWrite(led, LOW);
delay(500);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.