Go Down

Topic: delay() and delayMicroseconds() not working properly (Read 420 times) previous topic - next topic

45gfg9

OS: Windows 10 Home [10.0.16299.248]
IDE: 1.8.5
Boards: Uno Rev3, Nano (clone)


A delay() sentence is in my project and just like this:

delay(500);

But when I uploaded it on an Nano clone, I can't see any delay.
After that I uploaded the built-in "Blink" to it, but still can't see any delay, LED looks always on.

I got an Arduino Uno Rev3 and uploaded Blink. Still the same.

Same thing happens to delayMicroseconds().

"BlinkWithoutDelay" works fine.
Uploading with Web Editor works fine.

Then I tried, when I use

delay(230000);

It seems like 1 sec.

It works fine maybe 3 months ago, but I just discovered this problem until today.

So is this the IDE's problem or boards' ? Or is here anyone encountered the same problem?
"Any device is hackable. Take advantage of it. " - Hacknet::World.exe

DrAzzy

Is that all of your sketch, just blink with bigger numbers?
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

45gfg9

Is that all of your sketch, just blink with bigger numbers?
Yes. The number is not milliseconds or something.
"Any device is hackable. Take advantage of it. " - Hacknet::World.exe

CrossRoads

delay(500) delays for 500milliseconds, or 1/2 second.
delayMicrosecond(100000) delays for 100,000 microseconds, 100 millisecond, 0.1 second.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

45gfg9

delay(500) delays for 500milliseconds, or 1/2 second.
delayMicrosecond(100000) delays for 100,000 microseconds, 100 millisecond, 0.1 second.
No no no
The delay() on my computer not working as millisec.
I can't get a second's delay with delay(1000) or delayMicroseconds(1000000)
Instead, delay(230000) would give about 1 sec delay
"Any device is hackable. Take advantage of it. " - Hacknet::World.exe

CtrlAltElite

I can't see any code, and I'm not sure how this is an "Installation and Troubleshooting" question, but other than that, this is an interesting problem.
Has there been an outbreak of the stupid virus, and I didn't get the memo?

45gfg9

I can't see any code, and I'm not sure how this is an "Installation and Troubleshooting" question, but other than that, this is an interesting problem.
I guess this is the problem with IDE... so maybe Troubleshooting :(
And you can use Blink as code.
"Any device is hackable. Take advantage of it. " - Hacknet::World.exe

CtrlAltElite

I guess this is the problem with IDE... so maybe Troubleshooting :(
And you can use Blink as code.
But we can't see any of your code. If we could, it may prove to be a Programming problem
Has there been an outbreak of the stupid virus, and I didn't get the memo?

45gfg9

But we can't see any of your code. If we could, it may prove to be a Programming problem
Well, here's my code
In fact I'm testing my own library
So I guess I should also post on that library
... but I believe my library does not affect the rest of Arduino.h ...
"Any device is hackable. Take advantage of it. " - Hacknet::World.exe

ieee488

... but I believe my library does not affect the rest of Arduino.h ...
Famous last words.


DrAzzy

There is an internal function named init() which is used to set up the timers for (among other things) the timing functions. It is called immediately before setup().

Rename your init() function to something else and that should fix the problem.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

45gfg9

There is an internal function named init() which is used to set up the timers for (among other things) the timing functions. It is called immediately before setup().

Rename your init() function to something else and that should fix the problem.
I renamed init() to S7init()
Nothing changed
...
I guess it has nothing to do with internal init()
Cuz... uploading with Web Editor works fine...
"Any device is hackable. Take advantage of it. " - Hacknet::World.exe

45gfg9

It works on another PC. With unchanged init() function.
So I guess I should completely reinstall IDE on that PC...
"Any device is hackable. Take advantage of it. " - Hacknet::World.exe

Go Up