Is there a way to output a sinusoidal wave with an arduino? Perhaps using PWM? It would be nice to be able to simulate something around 10kHz. Is this even possible with the hardware on the Uno?
Look for DDS (Digital Direct Synthesis) which uses a low pass filter as mentioned in the other answers:
It then uses a varying PWM signal to create a sine wave:
All you need in order to implement it with an Arduino, including the source code for the PAM generator, can be found in this article.
Yes, you use a low pass filter combined with PWM. The lower the duty cycle the lower the value of your output. So you modulate your duty cycle like a sinusoid and pass the PWM output through a LPF. The output of the LPF will then be a sinusoidal waveform, though it will have a DC offset.
Not quite an Arduino, but I remember a specific lab exercise that required me to do this in my university microcontrollers course using an AT90S8515 - and as I recall, it required some assembly programming to get the frequency into the tens of kHz... in fact here's the lab description.
Other than PWM + Low Pass Filtering, another way is to use an R-2R ladder DAC, and drive the output with a PORT. But you're not going to get much frequency out of it using the
digitalWrite function. Like I said, at a minimum you'll need to do direct port assignments.