Function generator with Arduino Nano I'm trying to convert the project here to an Arduino Nano.

I scaled the waveforms from 12 bit to 8 bit values. I replaced the analogReadResolution and analogWriteResolution calls with pinMode(10, OUTPUT) and pinMode(11, OUTPUT) and changed the two analogWrite calls to write to pins 10 and 11. Otherwise the program is unchanged.

My thinking (and this is where my poor electronics skills come into play) is that I just need a simple low pass filter to convert the PWM into the appropriate waveform (which, at startup, ought to be a sine wave on both pins). According to the article, the frequency generator tops out at 170Hz. I figure the PWM signal is going to be significantly higher than that, so I use R=3.3K and C = .1uF for my RC filter which ought to give me a -3dB at about 480Hz, but what I'm seeing on my scope is a mess. Not a stable signal at all.

This is the waveform I'm seeing on my scope:



Can someone educate me?

Update: BTW, this is the initial waveform which ought to be a sine wave.
The PWMs on pins 10 and 11 of the Arduino Nano run at 488 Hz. That's what you are seeing on the scope. The code you are using was meant for an Arduino Due, which has real digital-to-analog converters.

Edit: You can tune the PWM to run as high as F_CPU/256 by
reconfiguring the timers 1 and 2 to “fast PWM” mode, instead of phase
correct PWM, and setting their prescalers to 1 instead of 64. This
should raise the PWM frequency to 62.5&nbsp;kHz, given that the Nano has
a 16&nbsp;MHz clock.

The following code should do exactly this. You can put it somewhere
inside your setup(). Warning: I have not tested this code. This
will change the PWM frequency on pins 10 and 11, but also on pins 3 and
9, which share the same timers. It will probably break the tone()
Arduino function.

// Set PWM frequency to 62.5 kHz on pins 3, 9, 10 and 11.
TCCR1A = 1&lt;&lt;WGM10;
TCCR1B = 1&lt;&lt;WGM12 | 1&lt;&lt;CS10;
TCCR2A = 1&lt;&lt;WGM21 | 1&lt;&lt;WGM20;
TCCR2B = 1&lt;&lt;CS20;