Skip to content

Instantly share code, notes, and snippets.

@conspirator
Created July 4, 2012 04:20
Show Gist options
  • Save conspirator/3045276 to your computer and use it in GitHub Desktop.
Save conspirator/3045276 to your computer and use it in GitHub Desktop.
Arduino: Blink v1
/*
Blink
Turns on an LED on for 1/4 a second, then off for 1/4 second, after the third blink, hold for 1 1/4 seconds and repeat.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
int i = 0; // create a 'crement var
int block = 250; // create default time unit
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(block); // wait for a 1/4 second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
if (i == 2) {
delay( 5 * block ); // wait for 2 seconds after third blink
i = 0; // set i back to 0
} else {
delay(block); // wait for a 1/4 second
i++; // increment i by 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment