 # Variable Frequency Square wave generation with amp

Hello all,

Just for fun, I want to see if I can generate square waves of varying frequencies, and send them to my amp so it can play different notes. I began by stripping an RCA plug, plugging the ground wire into ground, and the signal wire into digital pin 9. Since 9 is a PWM pin on my Duemilanove, I thought i might get some interesting results. I first set it to 100, and got a crisp, relatively high frequency sound. After wiring a pot in to control my PWM value, I noticed PWM makes almost no change. It is now apparent to me that I need to generate my own waves, and use the pot to control the frequency, not the wavelength. I'm relatively new at all of this, so if you do post some sample code or something, I'd greatly appreciate it if it was easy for a newbie like me to follow. Any help, however, would be much appreciated.

The standard PWM is a fixed frequency, but a variable mark:space ratio, meaning that the number of cycles per second remains constant, but the ratio of "ON" (high) time to "OFF" (low) time varies.

Frequency and wavelength are opposite sides of the coin - for a given speed of sound (V), the wavelength (lambda) and frequency (f) are given by the equation V= f x lambda. So, you can't control the frequency without controlling the wavelength.

(unless you also vary the speed of sound ;) )

You may get some inspiration from this project: http://www.rpi.edu/~kouttd/03/Rage_against_the_arduino.html

o control the frequency, not the wavelength.

The wavelength is only a parameter for a propagated wave like a sound wave or a light wave. The inverse of the frequency is the period or time period. As mentioned the PWM is a constant frequency so you would not expect to here much difference. In fact the harmonic content of the wave changes as you change the PWM so there will be some change in the sound but not the sort you might be expecting.