Created
February 27, 2018 09:45
-
-
Save MargenauMaker/93d66d645e8ed71caca041346d708e38 to your computer and use it in GitHub Desktop.
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
/* Create a sketch to make the lilymini blink an SOS then repeat. | |
* This version uses the "for" loop to shorten the code. The syntax for the "for" loop uses an initialization, | |
* condition and increment to manage how many times the loop is carried out. It also requires | |
* a brace "{" at the beginning and } at the end. The sketch below uses the blue on the RGB to | |
* denote when the larger loop completes. | |
* | |
*/ | |
int A = 3; | |
int B = 4; | |
int c = 7; | |
int short_pause = 300; //short pause for dot | |
int long_pause = 800; //longer pause for dash | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode (A, OUTPUT); | |
pinMode (B, OUTPUT); | |
pinMode (c, OUTPUT); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
for (int x = 0; x < 3; x++) { | |
digitalWrite (A, HIGH); | |
digitalWrite (B, HIGH); | |
delay (short_pause); | |
digitalWrite (A, LOW); | |
digitalWrite (B, LOW); | |
delay (short_pause); | |
} | |
delay (500); | |
for (int x = 0; x < 3; x++) { | |
digitalWrite (A, HIGH); | |
digitalWrite (B, HIGH); | |
delay (long_pause); | |
digitalWrite (A, LOW); | |
digitalWrite (B, LOW); | |
delay (long_pause); | |
} | |
delay (500); | |
for (int x = 0; x < 3; x++) { | |
digitalWrite (A, HIGH); | |
digitalWrite (B, HIGH); | |
delay (short_pause); | |
digitalWrite (A, LOW); | |
digitalWrite (B, LOW); | |
delay (short_pause); | |
} | |
delay (long_pause); | |
digitalWrite (c, HIGH); | |
delay (short_pause); | |
digitalWrite (c, LOW); | |
delay (short_pause); | |
delay (long_pause); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment