Skip to content

Instantly share code, notes, and snippets.

@pepasflo
Created March 7, 2018 00:12
Show Gist options
  • Save pepasflo/34cd27959a74540a1a9fc9e74cb7b253 to your computer and use it in GitHub Desktop.
Save pepasflo/34cd27959a74540a1a9fc9e74cb7b253 to your computer and use it in GitHub Desktop.
Arduino sketch for spelling out "S.O.S." in morse code
int led_pin = 13;
void setup() {
pinMode(led_pin, OUTPUT);
}
int dit_high = 60;
int dit_low = 120;
int dash_high = 120;
int dash_low = 60;
int period = 180;
void dit() {
digitalWrite(led_pin, HIGH);
delay(dit_high);
digitalWrite(led_pin, LOW);
delay(dit_low);
}
void dash() {
digitalWrite(led_pin, HIGH);
delay(dash_high);
digitalWrite(led_pin, LOW);
delay(dash_low);
}
void loop() {
dit();
dit();
dit();
delay(period / 2);
dash();
dash();
dash();
delay(period / 2);
dit();
dit();
dit();
delay(period / 2);
// sleep
delay(period);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment