I am coding a flight data recorder, and i am trying to display a number in binary using LEDS, however in the for loop it goes through i =0 to i =3 , as each variable is linked to an LED, but after i is equal to 3, it loops back to 0 and stops my FDR from functioning properly. And ive got no idea how to fix the for loop, any suggestions?
for (int i=0; i <= 3; i++)
{
Serial.print("I value:");Serial.print(i);
Serial.println();
Serial.print("guesser"); Serial.print(i+3-2*counter);
Serial.println();
Serial.print("digits");Serial.print(digits[i+3-(2*counter)]);
Serial.println();
if (digits[i+3-(2*counter)]==1)
{
digitalWrite(ledPins[i], HIGH);
Serial.print("THIS BULB LIT UP:");Serial.print(i);
}
else {
digitalWrite(ledPins[i], LOW);
}
counter=counter+1;
delay(1000);
}
loop()? If not, where is it? If so, it's normal that it will be called over and over again.