When I do this, I see the three-blink bootloader sequence and then the LED blinks on and off with a period of about a second, which, I perceive, was your intent. I can reset by opening a terminal and I can reset by pressing button. All is Good on my Centos 5.5 system with Arduino version 0022 , avr-gcc version 4.3.4 built from source and with the latest version of the Optiboot boot loader from http://code.google.com/p/optiboot/

However, if I delete the delay() statement, it repeatedly does the bootloader three-blink thing on the LED on pin 13 whenever I hit the button or when I open a terminal, and never gets to the code in the sketch.

If you are using Windows, then never mind (but I already said that). Maybe some of the other helpers can come up with something.

The code itself works just swell on Duemilanove boards as well as the UNO with my Linux system, although I might have written it a little differently. With the Duemilanove boards it doesn't need the delay() statement.

Quote

The problem is that something weird is with division.

I can state unequivocally (and I am unanimous in that) that it has nothing do do with division.

No, I'm using Windows 7 64 bit. But this is not the bootloader problem, because the code works if it happens to reset correctly.

Quote

I added a delay of 1 millisecond in the loop. Here's the code:

I tried that also and forget to tell. I thought that it helped, but if you are passioned enough to press the reset button, then the problem comes anyway.

And why? Because the 1 ms loop takes the most of the time from the main loop, so the certainty to press the reset while in division goes minimal.

That it the thing it took me so long to find that division is the problem. Originally I had so much larger main loop and the problem game very seldom, I even ignored it at the beginning.

And my real concern is that if everybody that has division in his code has the same problem. Normally people do not press the the reset button all the time, but I think also interrupt in the same case hangs the Arduino. And that is the main concern.

Generally speaking, I think it's really important for posters to tell us exactly what system they are using. Sometimes it makes a difference to people who would like to help.

One final question, and then I am done for this thread: Does the symptom persist if you unplug the UNO's USB connection and power it externally?

Anyhow...

I'm sorry to have wasted the board's bandwidth on something that couldn't help you. But: See Footnote.

Regards,

Dave

Footnote:Putting in the delay() that keeps away from micros() is, at best, a Band-Aid that masks the real problem: A system bug that causes the Bad Thing to happen.

What I forgot to mention is that the UNO was absolutely unusable on my Linux system until I updated the firmware in the USB interface chip. That made it "almost good enough" for casual testing, but it still has problems that I simply can't reproduce with the FTDI interface on Duemilanove boards or other designs that use the FT232 chip for the USB interface.

For Linux users, I still think it's a matter of interaction between the Bootloader and the Operating System's treatment of /dev/ttyACM0. Whether it can be fixed with a new load of the bootloader or updating firmware in the ATmega8U2 USB chip on the UNO or a change in the Operating System's handling of USB with /dev/ttyACM0 is still awaiting discovery and fix.

Think that one needs an L for long too. Otherwise still no clue Update: I confirm that the code without the L does behave "strange" on my UNO too.* adding the L does not solve it* adding UL does not solve it

if ( dOn && ( n1000 < 500000L ) ) { digitalWrite(dummyPort, 0); dOn = false; }[glow] delay(1);[/glow]}Adding shortest delay seems to make it more stable ... what does micro() do low level as that is also a constant factor in the code?

Yes it helps, because then you minimize the change to hit reset during modulo (%). But still it is possible to hang if you are patient enough pressing the reset button. So this is not a way to replace this, one only hides the real problem.

Quote

... what does micros() do low level as that is also a constant factor in the code?

it gives the microseconds from the last restart. And notice that if one uncomments the two lines: