Go Down

### Topic: Tone library using 16 bit timer (Read 1 time)previous topic - next topic

#### mako

##### Oct 18, 2010, 10:30 pm
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

#### gigawatts

#1
##### Oct 20, 2010, 08:13 am
I second this question. I have been looking to do the exact same thing.

#### mako

#2
##### Oct 21, 2010, 09:56 pmLast Edit: Oct 21, 2010, 10:01 pm by mako34 Reason: 1
hi, thank you to mr Brett Hagman of Rogue Robotics
for the library and the explanation,
tone library:

I have put togher this code, to generate 1Hz, 10 Hz, and 50Hz as test,
Code: [Select]
`#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

#### gigawatts

#3
##### Oct 21, 2010, 11:52 pm
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

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!

Go Up

Please enter a valid email to subscribe