Thursday, February 25, 2010

Task 19 - program to get one led to increase its rate of blinking from 100ms to1sec.

//for-loop with counter variable i.
//program to get one led to increase its rate of blinking from 100ms to 1sec.
//Repeating forever.
// by Adam Randall


int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 12
int i = 100;
// The setup() method runs once, when the sketch starts


void setup() {
// initialize the digital pin as an output:
pinMode(redLedPin, OUTPUT);
}


void loop()
{
for (i=100; i<1000; i=i+50){ // for loop counter increasing i by 50
digitalWrite(redLedPin, HIGH);//sets the pin to on
delay(i);//delay
digitalWrite(redLedPin, LOW);//sets the pin to off
delay(i);//delay
}
i=100; //resets i back to 100
}


}

No comments:

Post a Comment