Skip to main content
added 31 characters in body
Source Link
Spehro 'speff' Pefhany
  • 422.9k
  • 23
  • 352
  • 952

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).

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.

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).

Source Link
Spehro 'speff' Pefhany
  • 422.9k
  • 23
  • 352
  • 952

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.