Go Down

Topic: led blinking too fast (Read 5778 times) previous topic - next topic

raphaelss

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

raphaelss

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.

robtillaart

PLease post your code as we cannot see it.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Grumpy_Mike

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

raphaelss

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.

retrolefty

Quote
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

raphaelss

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

AWOL

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

The usual stuff.

raphaelss

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

/*
  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.



Grumpy_Mike

Quote
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?

stelar

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.

AWOL

Which version of the IDE?

stelar

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

AvNix

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):
Code: [Select]

#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.

Go Up