led blinking too fast

When i run the blink example, it blinks too fast. Like it had a much smaller delay. It wasn't behaving this way earlier. What could be wrong?
thanks in advance

more info:
i inserted a serial part in the program, basically just Serial.println(millis()), to see how it was "counting time", and with a serial communication part in the sketch delay() seems to work at a proper pace, but with without it, it just goes much faster.

PLease post your code as we cannot see it.

This is because printing takes time, it is adding to your delay.

it's just the Blink example with the original delay(1000), but it's blinking faster than that. What i did was add Serial.begin at the setup and Serial.println at the loop, but just the Serial.begin is enough to make it blink at right pace.

When i run the blink example, it blinks too fast. Like it had a much smaller delay. It wasn't behaving this way earlier. What could be wrong?
thanks in advance

It may not be running the blink program at all, but rather locked up in some problem. Can you re-upload the standard blink sketch and tell us if it's blinking at the correct rate or not, or does it report any kind of upload error?

Lefty

It uploads normally - no errors. But again, way faster than turning on/off every second.

Time ten blinks, tell us how long it takes.
Tell us what board you're using.
Post your code.

The usual stuff.

It's the nano 2.3
The code is just the standard blink example:

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}

and it takes about 5 seconds for ten cycles.

But again, way faster than turning on/off every second

That code should turn on / off every two seconds.

What sort of Arduino are you running?

Hi,

I'm also having the exact same problem:

  • LED is blinking too fast when running the blink example
  • uploading of sketch has no error
  • adding Serial.begin(9600) the top of the loop helps, and the LED blink timing is as per intended

By the way, I'm using Arduino Duemilanove ATMega328.

Which version of the IDE?

I'm using Arduino Alpha 0022 on Linux 32-bit.

Got the same situation - on one environment I cannot run any sketches. All compiles/uploads fine, but not working as expected.
So I started with very simple Blink sketch. It is working fine with IDE 0022 and GCC-4.3.3/Binutils-2.19 on MacOS X.
When I'm trying to compile/run it on Linux with GCC-4.5.3/Binutils-2.22 (IDE 0022/23/1.0 x64) - Blink does not work. LED starts flashing very fast.
If I substitute arduino's delay() with official one (from toolchain):

#include <util/delay.h>
.... SKIPPED ....
_delay_ms(1000);
.... SKIPPED ....

LED is blinking as expected.

So I suspect some optimization changes in GCC-4.5 or poor code (or assumptions) from arduino side makes newer GCC compile unusable code.
As many libraries/sketches relies on delay() function - this makes them unusable too.