//for-loop with counter variable i.
//It will get one led to blink 20 (different value) times, using the for-loop, then the other to blink once.
//Repeating forever.
// by Adam Randall
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 12
int del =50;
int i = 0;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
void loop()
{
for (i=1; i<20; i++){ // for loop counter
digitalWrite(ledPin, LOW); //sets the pin to off
delay(del); //delay
digitalWrite(redLedPin, HIGH);//sets the pin to on
delay(del);//delay
digitalWrite(redLedPin, LOW);//sets the pin to off
delay(del);//delay
}
digitalWrite(ledPin, HIGH);//sets the pin to on
delay(del);//delay
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment