[C.CC USERS] Piezos under Plumbing

Adam Sampson ats at offog.org
Fri Feb 19 11:08:28 GMT 2010


Matt Jadud <matt at concurrency.cc> writes:

> Looking at http://www.arduino.cc/en/Tutorial/PlayMelody it might be
> difficult.

Yes -- you won't be able to pull that approach off using the TVM; even
if we had microsecond-precision timers, I don't think you'll be able to
get it to cycle fast enough to play high notes. I haven't tried
measuring how fast it actually goes, but if you've got a scope or a
multimeter with a frequency counter then you could try writing a loop
that just toggles an output pin on and off as fast as possible, and
seeing what the maximum frequency you can get out of it is.

You can probably do a better job by using the AVR's PWM outputs. It
looks like it should be possible to get Timer 1 to generate
audio-frequency waveforms with sufficient accuracy for musical purposes,
although you may need to play with the prescaler a bit (check you don't
step on the TVM's internal timer use at the same time). What you'd want
to end up with is another Wiring-like call to set the frequency for each
PWM output, and then you can just look up note frequencies in a table.

Alternatively, have you considered just doing percussion? You can get a
variety of interesting thunk/whirr/buzz noises out of solenoids, relays
and motors...

Thanks,

-- 
Adam Sampson <ats at offog.org>                         <http://offog.org/>




More information about the users mailing list