06 March 2010

Task 19 - like Task 18 but the Yellow LED blink time increases: 100ms to 1 sec

/*
* Project: Blink2-Task 19
* Author: Jane-Maree Howard
* Date: Saturday 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 5 times & the other once, & repeat
* Again, the difference from task 15/16 is that here we use a 'for-loop'
* There is also an increasing blink rate of the Yellow LED, from 100ms to 1 * sec.This is achieved with an incrementing variable outside the 'for-loop'
*/

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 = 100; // delay variable - now 100 milliseconds
int dLayXier = 1; // delay multiplier to ramp up the yellow LED blink rate from 100ms to 1 sec

// 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 4 seconds
digitalWrite(ledPin, HIGH); // turn on-board LED on
delay(dLay*40); // delay 4 seconds (40 * 100ms)
}//end setup()

// Loop turns yellow LED (pin12) off, red LED (pin 11) on, waits six seconds,
// turns red LED off & runs a 'for-loop' 5 times:
// turn yellow LED on & off, with increasing delay each time loop runs, &..
// ..repeats endlessly while Arduino has power
void loop()
{
if (dLayXier > 10) dLayXier = 1; // check multiplier value
digitalWrite(ylwLedPin, LOW); // turn yellow LED off
digitalWrite(redLedPin, HIGH); // turn red LED on
delay(40*dLay); // delay 4 seconds
digitalWrite(redLedPin, LOW); // First turn red LED off
for (int i=0; i<5; dlayxier =" ++dLayXier;">

3 comments:

  1. I'm not sure i entirely understood Task 19 instructions;
    i interpreted that as incrementing the LED blink time..

    OMG the 1-dayer's tight!! 8 wickets down, 35 runs off 30 deliveries 2 go..

    ReplyDelete
  2. Lost by 13 runs :-(
    Dan Vettori finally goes for 70..
    Tim Southee left there on 1..

    1-all in the series!

    ReplyDelete
  3. Maybe if i wasn't so interested in the Cricket i'd've figured out what Task 19 REALLY means:
    that the LED goes 'bip-bip-biip-biiip-beep-beeep'

    ReplyDelete