Pages: [1]   Go Down
Author Topic: Hi, Simple question Blink without delay()  (Read 422 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a way to blinnk a led without the delay() function?

i whant to blink a led every 1 min, but in the normal way i use something like this

Code:
digitalWrite(13, LOW);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);

but i whant to blink and be able to push a button or something else but when the program is in the delay(); part the program are in "pause", so there is a way to blink a led without stop the program for the delay duration?

Like using PWM that is the same but alot faster xD
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There is a way to blinnk a led without the delay() function?
Of course there is. There is even an example called, not unsurprisingly, Blink Without Delay.
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or instead of having to deal with all the timer tick polling, look at some of the timer libraries.
Some use interrupts, some depend on getting updates in loop()
--- bill

http://arduino.cc/playground/Code/Timer
http://arduino.cc/playground/Main/MsTimer2
http://arduino.cc/playground/Main/FlexiTimer2
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 484
Posts: 18768
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a way to blinnk a led without the delay() function?

http://www.gammon.com.au/blink
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thx alot that is helpfull, when i go home i try these
Logged

Pages: [1]   Go Up
Jump to: