06 March 2010

Task 20 - ramping the LED rate UP then DOWN again

/*
* Project: Blink2-Task 20
* 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, & repeats
* There is also a varying blink rate of the Yellow LED,
* from 10ms up to 1 sec & back down again.
* Here we use two 'for-loops': one to ramp up the Delays, &
* the other to ramp them back down again
*/

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 = 10; // delay variable - now 10 milliseconds

// 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*400); // delay 4 seconds (400 * 10ms)
}//end setup()

// Loop turns yellow LED (pin12) off, red LED (pin 11) on, waits 2 seconds,
// turns red LED off & runs a 'for-loop' 5 times:
// turn yellow LED on & off, with varying delay each time loop runs, &..
// ..repeats endlessly while Arduino has power
void loop()
{
//Ramps delays UP - Red LED stays ON thru Yellow LED loop
for (dLayXier=1; dLayXier<=100; dLayXier++) //ramp delay times UP { digitalWrite(ylwLedPin, LOW); // turn yellow LED off digitalWrite(redLedPin, HIGH); // turn red LED on & leave it ON delay(200*dLay); // delay 2 seconds for (int i=0; i<5; dlayxier="100;">1; dLayXier--) //ramp delay times DOWN
{
digitalWrite(ylwLedPin, LOW); // turn yellow LED off
digitalWrite(redLedPin, HIGH); // turn red LED on
delay(200*dLay); // delay 2 seconds
digitalWrite(redLedPin, LOW); // First turn red LED off
for (int i=0; i<5;>

1 comment:

  1. Y'see, i'm watching the LEDs now & the Red LED is now turning off during the Yellow LED blinks..
    ..but it's taken FOREVER to get there & really, i don't think that's it.

    i'm gonna revise this..

    ReplyDelete