help with PWM


Can anyone help me to understand how I can use the arduino to produce a simple tone on an 8 ohm speaker that has the volume modulated by a pot and the frequency modulated by an IR sensor. I know how to hook the sensors up and can read them into the arduino and have been able to produce a steady tone using the analodWrite command.. but I can't seem to figure out how to adjust the frequency or the volume of that tone. I have looked at the tutorials but they are all for playing melodies and I get lost in the code.

Any help is appreciated, Dave

should be able to use this, with a piezo

and use a power driver or your 8ohm speaker The LM386 is an audio amplifier IC, Radio Shack Catalog # 276-1731