06 March 2010

Task 14 - like Task 13 but with the LEDs reversed



/*

* Project: Blink2-task 14
* Author: Jane-Maree Howard
* Date: Tuesday 06/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, LOW); // turn yellow LED off
digitalWrite(redLedPin, HIGH); // turn red LED on
delay(6*dLay); // delay 6 seconds
digitalWrite(ylwLedPin, HIGH); // turn yellow LED on
digitalWrite(redLedPin, LOW); // turn red LED off
delay(dLay); // delay 1 second
}//end loop()


1 comment:

  1. The actual HARDWARE has NOT been swapped around,
    the Yellow LED is still pin 11 & the Red LED, pin 12;
    They're just switched HIGH & LOW differently from Task 13

    ReplyDelete