/*
Alternate Blink
1. Turn on LED1, turn off LED2 for
1 second (at the same time)
2. Turn off LED1, turn on LED2 for
1 second (at the same time)
3. Repeat
*/
int pinA=A1;
int pinB=A2;
void setup() {
pinMode(pinA,OUTPUT);
pinMode(pinB,OUTPUT);
}
void loop() {
//turn on pinA and turn off pinB
digitalWrite(pinA,HIGH);
digitalWrite(pinB,LOW);
//wait 1 sec
delay(1000);
//turn off pinA and turn on pinB
digitalWrite(pinA,LOW);
digitalWrite(pinB,HIGH);
//wait 1 sec
delay(1000);
}
Only one pin lights up. For example, if i put A1 as the first int, then only A1 lights up. If I put A2 as the first int, only A2 lights up. Why can't they alternate flashing?
Don't see a problem with the code, so perhaps the wiring needs closer inspection. Are you wired to A1 and A2? Do you have both LEDs in the correct way? With resistors on each, I hope.
Oh, I just tested again after you said, and the pins are alternating. I think it was a matter of the shield pins not being seated, finicky. Thanks for help!
If you had initially mentioned that you were using a shield plugged into the Arduino then it is possible that someone would have suggested checking that it was plugged in firmly and making a connection