Created
April 22, 2012 20:32
-
-
Save zippy1981/2466705 to your computer and use it in GitHub Desktop.
Arduino SOS Program
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
/* | |
SOS | |
Sends SOS in morse code on the Arduino board. | |
For more information see http://en.wikipedia.org/wiki/Morse_code | |
Copyright 2012 Justin Dearing. | |
*/ | |
int dotDur = 125; | |
int dashDur = dotDur * 3; | |
int wordPause = dotDur * 7; | |
void setup() { | |
// initialize the digital pin as an output. | |
// Pin 13 has an LED connected on most Arduino boards: | |
pinMode(13, OUTPUT); | |
} | |
void loop() { | |
dot(dotDur); | |
dot(dotDur); | |
dot(dashDur); | |
dash(dotDur); | |
dash(dotDur); | |
dash(dashDur); | |
dot(dotDur); | |
dot(dotDur); | |
dot(wordPause); | |
} | |
void dash(int pauseDur) { | |
digitalWrite(13, HIGH); // set the LED on | |
delay(dashDur); | |
digitalWrite(13, LOW); // set the LED off | |
delay(pauseDur); | |
} | |
void dot(int pauseDur) { | |
digitalWrite(13, HIGH); // set the LED on | |
delay(dotDur); // wait for a second | |
digitalWrite(13, LOW); // set the LED off | |
delay(pauseDur); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment