Blink Experiments
After completing the Blink project, test yourself by trying these experiments.
| 1
| Modify the code so that it will turn the LED on for 2 seconds, and then turn the LED off for 1/2 a second.
|
|
|
|
Remember to press the Upload button to upload and run the program on the Arduino board after each time you make any modifications to your program.
|
| 2
| Modify the code so that the LED blinks like your heart beat.
|
|
| 3
| Make a Morse code sender to send out the emergency Morse code dot-dot-dot dash-dash-dash dot-dot-dot for SOS.
| Note the use of comments and blank lines in the code below to make the code easier to understand.
// Code to flash the Morse Code for SOS
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
// code to do three short flashes for S
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(600); // a longer delay to separate the S from the O
// code to do three long flashes for O
digitalWrite(13, HIGH);
delay(600);
digitalWrite(13, LOW);
delay(600);
digitalWrite(13, HIGH);
delay(600);
digitalWrite(13, LOW);
delay(600);
digitalWrite(13, HIGH);
delay(600);
digitalWrite(13, LOW);
delay(600);
// code to do three short flashes for S
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(1000); // a longer delay before repeating
}
|
|