This is on a custom Arduino PCB (32u4) that I am programming with a Sparkfun Pocket AVR Programmer. A different program that I was writing wasn't working the way I expected it to, so I tried the "BlinkWithoutDelay" example sketch from the Digital section of the examples.

https://media.discordapp.net/attachments/572565310679547946/650075749851856908/unknown.png ^ So you don't have to look it up yourselves. previousMillis is initialized to 0.

However, the LED seems to alternate states every 4 seconds instead of every 200 ms with this code. I increased the interval from 200 to 400, and the IRL time increased from 4 seconds to 8 seconds, so at the very least it's consistent that way. My first instinct is that the crystal is broken somehow, but I don't think I'd be able to flash the MCU in the first place if it was. So, does anyone have any idea what's happening? For the record, I had 5 of these PCB's assembled, and the first one worked perfectly for 2 months before something else broke. I've had this issue with the second and third PCB I've tried.

  • Check F_CPU when compiling and your lfuse setting. See engbedded.com/fusecalc for a convenient tool. Dec 1, 2019 at 13:21
  • Hey, sorry it took so long to get back. I'm using the arduino IDE, and I can't find the settings you're talking about in the preferences section, so I'd assume everything's fine on that front. I can turn compilation/upload to verbose and post that, if you think that would help.
    – Tri
    Dec 2, 2019 at 23:17
  • Never mind, check the answer I just posted.
    – Tri
    Dec 2, 2019 at 23:54
  • Arduino IDE has the fuses settings in boards.txt. Either you "Burn Bootloader" or use your programmer standalone with the avrdude utility. Dec 5, 2019 at 15:55

2 Answers 2


Factor 8 in timing smells like wrong fuses.

Perhaps you don't use an external oscillator, but the internal one?

  • It's a factor of 20, isn't it? And I'm pretty sure that it's using the external 16 Mhz oscillator on the board, unless that has been damaged somehow. I also just noticed that the second board is showing a factor of 16, coincidentally.
    – Tri
    Dec 1, 2019 at 11:36
  • I take that back about the second board. I just doubled the delay in the code and the observed delay stayed the same. I am very confused.
    – Tri
    Dec 1, 2019 at 11:39
  • You're right: it's hard to get 8 from a 4 and a 5. (Not sure how I assumed 10/5 just to explain the smell/odor ;) But then, your question is even more a miracle. Dec 1, 2019 at 13:00

On all of the new boards I had tested (excluding the first one that I said worked), I had not burned the bootloader. Burning the bootloader made the timing normal! If anyone can tell me why that's the case, I'll accept your answer as the "correct" answer.

  • 1
    Burning the bootloader also (usually) sets the fuses, as the particular fuse settings are specific to the bootloader. Thus DataFiddler's answer has the why, you have found the how to fix.
    – user85471
    Dec 3, 2019 at 5:03
  • :) so you deserve a +1 as well ... Dec 5, 2019 at 15:45
  • Awwww thank you
    – Tri
    Dec 6, 2019 at 18:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.