Created
March 1, 2018 00:16
-
-
Save morozgrafix/058677eb57d498a5c1bd1a588062bd9a to your computer and use it in GitHub Desktop.
SOS Blink to test out new Arduino Boards
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 Blink | |
My usual GO-TO script to test out a new Arduino board. | |
*/ | |
int dotLen = 150; // length of the morse 'dot' | |
int dashLen = dotLen * 3; // length of the morse 'dash' | |
int elemPause = dotLen; // pause between 'dots' and 'dashes' | |
int charPause = dotLen * 3; // pause between characters | |
int wordPause = dotLen * 7; // pause between words | |
int ledPin = LED_BUILTIN; // LED pin, built-in LED as a default | |
// DOT | |
void MorseDot() { | |
digitalWrite(ledPin, HIGH); // turn the LED on | |
delay(dotLen); // hold that state | |
} | |
// DASH | |
void MorseDash() { | |
digitalWrite(ledPin, HIGH); // turn the LED on | |
delay(dashLen); // hold that state | |
} | |
// LED Off | |
void LightsOff(int delayTime) { | |
digitalWrite(ledPin, LOW); // turn the LED off | |
delay(delayTime); // hold that state | |
} | |
// the setup function runs once when you press reset or power the board | |
void setup() { | |
// initialize digital pin LED_BUILTIN as an output. | |
pinMode(ledPin, OUTPUT); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
// SOS | |
// S | |
MorseDot(); | |
LightsOff(elemPause); | |
MorseDot(); | |
LightsOff(elemPause); | |
MorseDot(); | |
LightsOff(charPause); | |
//O | |
MorseDash(); | |
LightsOff(elemPause); | |
MorseDash(); | |
LightsOff(elemPause); | |
MorseDash(); | |
LightsOff(charPause); | |
//S | |
MorseDot(); | |
LightsOff(elemPause); | |
MorseDot(); | |
LightsOff(elemPause); | |
MorseDot(); | |
LightsOff(wordPause); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment