The following code uses a for loop to blink the LED on pin 13 5 times after blinking one on pin 12:
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
}
void loop()
{
digitalWrite(12, 1);
delay(500);
digitalWrite(12,0);
delay(500);
for (int i=0; i < 5; i++){
digitalWrite(13,1);
delay(500);
digitalWrite(13,0);
delay(500);
}
}
The number of times that the second LED flashes can be changed simply by changing the for statement for example: for (int i=0; i < 23; i++) will flash 23 times rather than 5
Sunday, February 28, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment