So in the GPIO utility from WiringPi there is a command to change the mode of the GPIO pins. There is input mode, output mode and PWM mode. What is the difference between output mode and PWM mode? Is output mode digital and PWM analog?

1 Answer 1


Input mode is for reading from the pin.

Output mode is for writing 0 or 1 to the pin.

PWM mode is for writing 0 and 1 to the pin in a rapid sequence. The pin will be cycled between on and off many time a second. For each cycle the pin will be on (1) for a time and then off (0) for a time. The proportion of time on for each cycle is called the dutycycle.

PWM output may be used to control the brightness of LEDs and the speed of motors. In effect you can think of PWM as digitally changing the voltage. Full on (100% dutycycle) give 3.3V at the pin. Full off (0% dutycycle) gives 0V at the pin and half on (50% dutycycle) gives 1.65V at the pin. This is a VERY SIMPLISTIC description. Research on line for a more accurate description.

  • I also believe that setting the pin to PWM engages the hardware PWM output support of the BCM2835. I also believe that only some pins may be eligible to be set to PWM.
    – Kolban
    Commented Dec 19, 2015 at 10:46
  • @Kolban The Pi has two hardware PWM channels (0 and 1). PWM channel 0 may be routed to GPIO 12 and/or 18. PWM channel 1 may be routed to GPIO 13 and/or 19. All those GPIO are available on the Pi's with the 40 pin expansion header. The compute module is different in that GPIO 40, 41, 45, 52, 53 may additionally be used.
    – joan
    Commented Dec 19, 2015 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.