06 March 2010

Task 15 - red LED on, yellow LED off, then red off & yellow blinks twice then red on again



/*

* Project: Blink2-task 15
* Author: Jane-Maree Howard
* Date: Tuesday 06/03/2010
* Platform: Arduino 18
* Purpose: To demonstrate variable blink times for 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
* In this case, One LED blinks twice & the other once, & repeat
*/

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) off, red LED (pin 11) on, waits six seconds,
// turns red LED off & yellow LED on & off twice, with one second delay each
time, &..
// ..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(redLedPin, LOW); // First turn red LED off
digitalWrite(ylwLedPin, HIGH); // NOW turn yellow LED on..
delay(dLay); // ..delay 1 second..
digitalWrite(ylwLedPin, LOW); // ..turn yellow LED off..
delay(dLay); // ..delay 1 second..
digitalWrite(ylwLedPin, HIGH); // ..turn yellow LED on & ..
delay(dLay); // ..delay 1 second
}//end loop()


4 comments:

  1. Cricinfo says we aren't looking good chasing the Oz

    But we might get there..

    ReplyDelete
  2. OH deary me!! Wot a long drawn-out story that task is - hehe
    (now that i've fixed it..)

    ReplyDelete
  3. Anyone watch 'The WotWots'?
    They're hilarious, & i especially like those little flying computer-chairs they whizz around in..
    I'd love something like that!! b fun :-)

    ReplyDelete