Pages: [1]   Go Down
Author Topic: Using tone() or similar function to blink the LED  (Read 708 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I have one question: is there any pre-built function that would do the similar thing as tone(), but at lower frequencies (let's say 1 to 10 Hz)?
I've tried tone() at low frequencies, but below 16 Hz it makes weird tone at hundreds of Hz.
Or is there any simple way to write that function, which could be called only once and not at each cycle of loop() (similar like tone() works), to produce blinking?
Thanks.
Logged

0
Offline Offline
Edison Member
*
Karma: 0
Posts: 1103
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tone uses the 8-bit timer2. The best this one can do is using prescaler 1024 and counting 256.
16 MHz/2/1024/256 = 32. So the problems should start at 32 Hz already...

You can try to modify the ton.ccp file to allow it to use a 16-bit timer... This is already pre-programmed but not enabled....
« Last Edit: August 15, 2010, 08:10:30 pm by mpeuser » Logged

Pages: [1]   Go Up
Jump to: