06 March 2010
Task 13 - Blink2 program with one LED mostly off, the other mostly on
/*
* Project: Blink2-task 13
* Author: Jane-Maree Howard
* Date: Tuesday 02/03/2010
* Platform: Arduino 18
* Purpose: To demonstrate variable blink times for the built-in LED &
external LEDs
* Operation: Sets up output pins (3 off) in setup() method;
* Declares pin definition variables (3 off)
* Defines loop() to perform various LED blinking & delay operations
*/
int ledPin = 13; // on-board LED connected to digital pin 13
int ylwLedPin = 12; // yellow LED connected to digital pin 12
int redLedPin = 11; // red LED connected to digital pin 11
int dLay = 1000; // delay variable
// The setup() method runs once, when the sketch starts
void setup()
{
// initialize the 3 digital pins as outputs:
pinMode(ledPin, OUTPUT);
pinMode(ylwLedPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
// turn on the on-board LED & wait 8 seconds
digitalWrite(ledPin, HIGH); // turn on-board LED on
delay(dLay*8); // delay 8 seconds
}//end setup()
// Loop turns yellow LED (pin12) on, red LED (pin 11) off, waits six seconds,
// turns yellow LED off & red LED on, waits one second, &..
// ..repeats endlessly while Arduino has power
void loop()
{
digitalWrite(ylwLedPin, HIGH); // turn yellow LED on
digitalWrite(redLedPin, LOW); // turn red LED off
delay(6*dLay); // delay 6 seconds
digitalWrite(ylwLedPin, LOW); // turn yellow LED off
digitalWrite(redLedPin, HIGH); // turn red LED on
delay(dLay); // delay 1 second
}//end loop()
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment