Pages: [1]   Go Down
Author Topic: Tone library using 16 bit timer  (Read 1156 times)
0 Members and 1 Guest are viewing this topic.
Lokombia
Offline Offline
Newbie
*
Karma: 0
Posts: 41
hackea negra hackea
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Ive seen this subject in other threads but not the explanation or how to
(sorry still learning!)

so I want to use the tone library to generate tones from 1 hz,
I saw that the 16 bit timer needs to be used,
so how to I have to change to accomplish this?

thank you
smiley-wink
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I second this question. I have been looking to do the exact same thing.
Logged

Lokombia
Offline Offline
Newbie
*
Karma: 0
Posts: 41
hackea negra hackea
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi, thank you to mr Brett Hagman of Rogue Robotics
for the library and the explanation,
tone library:
http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation

I have put togher this code, to generate 1Hz, 10 Hz, and 50Hz as test,
Code:
#include <Tone.h>

Tone freq1;
Tone freq2;

void setup()
{
 freq1.begin(11);
 freq2.begin(8);
}

void loop()
{
  freq2.play(1, 6000);
  delay (2000);
  freq2.play(10, 6000);
  delay (2000);
  freq2.play(50, 6000);
  delay (2000);
}

the freq2 is the timer of 16 bits
" The timers are allocated sequentially when you declare the Tone objects.  The second timer is Timer 1, which is a 16 bit timer."

Ok, very nice, thank you again Brett for the library and the explanation,
now to do my project !!! hahaha  smiley-grin
« Last Edit: October 21, 2010, 03:01:35 pm by mako34 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much for the reply! This had been driving me nuts trying to figure out how to use Timer1.

I had also PM'd Brett, but I guess he got back to you first smiley-grin

Can I assume that only Timer1 is 16bit? For my project, I actually need 2 outputs (to drive a speedometer and a tachometer, both requiring a square wave with a frequency range of 0 to ~230 hz).

Thanks again!
Logged

Pages: [1]   Go Up
Jump to: