Hi,
I hope everyone's having a nice day. I'm sorry if this is a basic question, but I would like to run the same function twice, except once on one pin, once on another. In this case, I want to blink an led twice (500 ms on, 500 ms off), turn it on for 2 seconds, turn it off, wait another 2 seconds, before doing it to the second led.
I'm just wondering, is it possible to tell the function execute once with one pin, than do it again, except with another pin (In other words, write a function, then just say do it once with A, once with B). If so, can this be done with a set of pins, instead of just one pin?
Also, is defining the pins as outputs at the beginning necessary? I think I once forgot to set the pin as an output pin, but I was just turning the pin on and off, and it didn't seem to cause an issue.
Thank you so much for your help!
void setup() {
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
}
void loop() {
for (i=0; i<2; i++) {
digitalWrite (A, HIGH)
delay(500);
digitalWrite (A, LOW);
delay(500);
}
digitalWrite (A, HIGH);
delay(2000);
digitalWrite(A, LOW);
delay(2000);
for (i=0, i<2, i++) {
digitalWrite (B, HIGH)
delay(500);
digitalWrite (B, LOW);
delay(500);
}
digitalWrite (B, HIGH);
delay(2000);
digitalWrite(B, LOW);
delay(2000);
}