This is just a quick project that you may find useful. I put it together to carryout out a couple of tests;

I’m sure it will be used again in the future for other small investigations.

The circuit shown is for testing a transistor. The LED is the load and a useful indicator of the output that won’t stress the transistor. The button is used to step through a number of preset PWM signals. The PWM control pin is digital pin 6. Depending on the Arduino you are using you may need to change this to suit your board.

PWM Tester Circuit

Or for a breadboard layout.

PWM tester on a Breadboard

Here is the Arduino Code. Adjust the SigPin number to suit the PWM pin you are using. Most of the code within the Loop is a simple around to debounce the button presses. All it does is ignore any further presses of the button until 2 seconds has elapsed since the last press. Download the sketch from here: PWMSignalGeneratorv0.ino


 * A simple Tester for the PWM output of an Arduino Nano
 * to use on any components that require a PWM signal.
 * Pins are;
 * Momentary button on D12 using a pullup resistor
 * PWM output on Pin D6

int OutputSigList[] = {0,20,80,120,180,255}; //List of signals to step through

int SigPin = 6;
int ButtonPin = 12;

int SpdPointer = 0; //Pointer for the speed from OutputSigList
long TimePrevPress = 0; //Carrier for previous time of button press

void setup()


void loop()
  if(millis()-TimePrevPress>2000 && int(digitalRead(ButtonPin) == HIGH))
    TimePrevPress = millis();
    SpdPointer = SpdPointer + 1; //advance the pointer to next speed.
    if(SpdPointer > 5)
      SpdPointer = 0; //wrap around the pointer list.

This is the raw PWM signal on the oscilloscope.

PWM Signal on Oscilloscope