Created
June 4, 2018 23:19
-
-
Save gallaugher/d763968939027abeee1ea433155b4438 to your computer and use it in GitHub Desktop.
SOS blink lon pin 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED 8 | |
#define dot_duration 250 | |
#define dash_duration dot_duration * 3 | |
#define pause_duration dot_duration | |
#define letter_pause dot_duration * 3 | |
#define word_pause dot_duration * 7 | |
void setup() { | |
pinMode(LED, OUTPUT); | |
Serial.begin(9600); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
// S | |
blink_for_time(dot_duration); | |
blink_for_time(dot_duration); | |
blink_for_time(dot_duration); | |
pause_for_time(letter_pause - dot_duration); | |
// O | |
blink_for_time(dash_duration); | |
blink_for_time(dash_duration); | |
blink_for_time(dash_duration); | |
pause_for_time(letter_pause - dot_duration); | |
// S | |
blink_for_time(dot_duration); | |
blink_for_time(dot_duration); | |
blink_for_time(dot_duration); | |
pause_for_time(word_pause - dot_duration); | |
} | |
void blink_for_time(int milliseconds){ | |
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(milliseconds); // wait for a second | |
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW | |
delay(pause_duration); // wait for a second | |
} | |
void pause_for_time(int milliseconds){ // wait for a second | |
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW | |
delay(milliseconds); // wait for a second | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment