# How to measure PWM on Oscilloscope?

I’m measuring the voltage level from an Arduino Uno PWM pin using an oscilloscope. I’m using analogWrite(pin, voltage) in the loop with pinMode(pin,OUTPUT) in the setup.

I set the trigger to edge (rising), auto mode, but all I see is noise. Tried zooming in/out and moving up and down on the screen to find the signal at 3.3 V but couldn’t find it.

What am I doing wrong?

• Did you connect the probe ground to the circuit? Also see if you scope has a calibration signal lug on it, and learn to view that first since it should be a nice square wave (though beware that won't require connecting the ground, unlike probing a distinct circuit does) – Chris Stratton May 20 '19 at 20:35
• I'm not up to speed on Arduinos... is analogWrite() the correct way to output a digital PWM signal? – spuck May 20 '19 at 20:40

Here is Sparkfun's example code:

int PWM_out_pin = 9; // Must be one of 3, 5, 6, 9, 10, or 11
// for Arduino Uno
void setup() {
pinMode(PWM_out_pin, OUTPUT);
}
void loop() {
byte PWM_out_level;
PWM_out_level = ... // Code logic to set output level
analogWrite( PWM_out_pin, PWM_out_level);
}


Use code similar to that (you need to have that loop structure, and I suggest, as a test, setting the output level to 127 so you get close to a square wave).

Make sure you use one of the valid pins and have your probe connected to that pin and the ground lead connected to GND of the Arduino.

If you still see nothing, try the autoset function on your oscilloscope, or just set the sweep to about 1-2ms/division and the sensitivity to 0.5 or 1V/division. Make sure your probe and scope are set to the proper sensitivity (usually 10:1 is best) and make sure the probe is not switched to ground if that is an option. Most scopes have a cal output that you can hook the probe to, and it has a similar frequency to the Arduino PWM (use that to check your scope).

Some oscilloscopes will give very strange readings if you set the sweep too slow in comparison to the signal (due to lacking an anti-aliasing filter).

• Thanks! I was using the wrong pin! (assumed that pin 3 would work). The other tips will definitely be helpful for the future as well! – Seth Shill May 21 '19 at 2:01