search
// Program name: easiestBlink05
//
// Purpose: Blinks onboard LED
//
// Program operation/flow:
// a function to blink onboard LED a set of some number of 'long' blinks of some duration
// followed by a set of some number of 'short' blinks of some duration,
// The function can be placed at end of setup to run once each reset or in loop to repeat
//
// Hardware configuration:
// uses on-board LED, in most cases output 13
// ------------------------------
// ******************** GLOBALS ********************
int ledPin = 13;
// ********************* USER PREFERENCES SET HERE:
// number of blinks
int numLongs = 2; // number of long blinks
int numShorts = 2; // number of short blinks
// time variables
int longBlink = 450; // duration
int betweenLongs = 450; // pause between blinks
int afterLongs = 600; // pause after the set
int shortBlink = 75; // duration
int betweenShorts = 175; // pause between blinks
int afterShorts = 600; // pause after short blinks
int afterAll = 1000; // end of loop before restart
// --------------- END globals --------------------
// ****************** SETUP ***********************
void setup() {
pinMode(ledPin, OUTPUT);
}
// --------------- END setup ----------------
// ******************* LOOP *******************
void loop() {
blinkset();
}
// ------------- END loop ---------------------
// ************** FUNCTION DEFS ******************
void blinkset() {
// first blink set is long
for (int x = 0; x < numLongs; x++) {
digitalWrite(ledPin, HIGH); // set the LED on
delay(longBlink); // wait
digitalWrite(ledPin, LOW); // set the LED off
delay(betweenLongs); // wait
} // end for
delay(afterLongs);
// next blink set is shorts
for (int x = 0; x < numShorts; x++) {
digitalWrite(ledPin, HIGH); // set the LED on
delay(shortBlink); // wait
digitalWrite(ledPin, LOW); // set the LED off
delay(betweenShorts); // wait
} // end for
delay(afterShorts);
delay(afterAll);
}
// ---------- END blinkset ---------------
// ----------- END Function Defs ---------------
// ---------------- END program ----------------