int j;
void setup()
{
for(j=2 ; j<=9 ; j++)
pinMode( j , OUTPUT );
digitalWrite( 2, HIGH );
}
void one()
{
digitalWrite( 3, HIGH );
digitalWrite( 4, HIGH );
}
void all_off()
{
for(j=3 ; j<9 ; j++)
digitalWrite( j,LOW);
}
void loop()
{
one();
delay(1000);
all_off();
delay(3000);
}
Trying to do a blinking "1" (stopped at 1 before continuing other numbers because of this problem ) with a single-digit 7 segment display. Where pin 2 is comnected to the com pins of the display.
Expected: display 1 for a second , then turn off for 3 seconds.
Reality: display1 for 3 seconds then turn off for a second.
Tried putting the delay functions in the one and all_off functions but no use.
Tried changing the delay(1000) to delay(7000) , the off time increased.
Tried changing the delay(3000) to delay(1000) , the turn on time changed to 1 second.
The code should work in order, should it not? What is happening? How to fix it?