So. Willie and made the Arduino blink. But not just blink. Blink and count up from 1 to 5, then start again.
So,
Blink.
Then Blink Blink.
Then Blink Blink Blink, etc.
Dig?
We got a little hung up with the nested for loops, but with a little help from our friends, we made it happen.
---
Here's the code:
// blink counting from 1 blink to 5
int counter = 0; // a counter for using with my blinking loop
int led = 13; // the led pin
void setup() {
pinMode(led, OUTPUT);
}
// my blink function
void blink(int g) {
for (int x = 0; x <= g; x++) {
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(200);
}
}
// my loop!
void loop() {
for (int counter = 0; counter < 5; counter++) {
blink(counter);
delay(800);
}
}
No comments:
Post a Comment