Hey, folks, I’m about to setup my Uno for ISP a bootloader on a blank chip but before I do that…
I was working through the tutorial examples last night and took Circuit #4 and got it running. Then, as a step in the learning process, I wrote code to make the 8 LEDs go in a circle (start with 1 through 8 then start over at number 1). I know this is really basic stuff but I’ve got a “problem” and I cannot figure it out.
Here’s what happens: program start, CurrentLED = 0, function call, delay, repeat function call. At beginning, LED 1 lights for 1/2 second, then LED 2 through 8, 1/2 second each. This is expected. What happens next is my problem; number 1 lights again but this time lights for 1 full second, followed by #2-8 lighting for 1/2 second each, then back to number 1 for a full second. This is so basic but I cannot figure out why this is happening.
I’m not sure if it’s cool to post code here (is it?) so I’m attaching a zip of the sketch. It’s so basic…but it’s still turning on LED 1 for a full second (after the first run through) when all the other LEDs stay on for only 1/2 second. I’d like to understand why.
hcb:
Hey, folks, I’m about to setup my Uno for ISP a bootloader on a blank chip but before I do that…
I was working through the tutorial examples last night and took Circuit #4 and got it running. Then, as a step in the learning process, I wrote code to make the 8 LEDs go in a circle (start with 1 through 8 then start over at number 1). I know this is really basic stuff but I’ve got a “problem” and I cannot figure it out.
Here’s what happens: program start, CurrentLED = 0, function call, delay, repeat function call. At beginning, LED 1 lights for 1/2 second, then LED 2 through 8, 1/2 second each. This is expected. What happens next is my problem; number 1 lights again but this time lights for 1 full second, followed by #2-8 lighting for 1/2 second each, then back to number 1 for a full second. This is so basic but I cannot figure out why this is happening.
I’m not sure if it’s cool to post code here (is it?) so I’m attaching a zip of the sketch. It’s so basic…but it’s still turning on LED 1 for a full second (after the first run through) when all the other LEDs stay on for only 1/2 second. I’d like to understand why.
[attachment=0]another_way.zip[/attachment]
Thank you.
–HC
Well, I didn’t quit…found Serial.println and found my problem. Of course, I only find the solution after I post the problem. In the Else If branch of the subroutine I was setting my variable CurrentLED to 0 AND turning it on then, on loop, the CurrentLED was 0 and hit the condition of (CurrentLED == 0) and turned 0 on again.