Lab1 - MyBlink

Submitted by antoine on Wed, 01/30/2013 - 15:43

 

/*
  Blink
 Turns on an LED on for one second, then off for one second, repeatedly.
 
 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;
int timer = 0;
 
// 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:
void loop() {
  if (timer < 50) {
    digitalWrite(led, HIGH);
    delay(50);
    digitalWrite(led, LOW);
    delay(50);
    timer += 1;
  }
  else if (timer < 75) {
    digitalWrite(led, HIGH);
    delay(100);
    digitalWrite(led, LOW);
    delay(100);
    timer += 1;
  }
  else if (timer < 80) {
    digitalWrite(led, HIGH);
    delay(500);
    digitalWrite(led, LOW);
    delay(500);
    timer += 1;
  }
  else {
    digitalWrite(led, LOW);
  }
}
The beast...
0
Your rating: None
Drupal theme by Kiwi Themes.