0

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);
    } 
2
  • 3
    Is this code in loop()? If not, where is it? If so, it's normal that it will be called over and over again. Commented Oct 11, 2018 at 15:36
  • 4
    Would you mind posting a Minimal, Complete, and Verifiable example? Commented Oct 11, 2018 at 15:36

1 Answer 1

1

In the Arduino environment, the loop() function is called again and again.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.