ESP32 Bit Pirate home
  • DIO
  • Beginner
  • 5 min
  • Serial CLI

Recipe · Beginner · DIO

How to generate PWM or move a servo

A simple PWM output is useful for testing an LED driver, input pin, optocoupler, or servo signal path.

PWM signal driving a servo.
Generate a quick test signal from the bench without writing a sketch.

Wiring View

BP Signal inputGPIOGNDBP GNDServo powerexternal supply
Generated from the wiring summary: to BP.
Step 1

Commands

Run the typed commands first. If the command opens an interactive shell, select the named action from the shell menu instead of treating it as another CLI command.

Result

What success looks like

A stable PWM output confirms the target input path. For servos, power the servo separately and share ground with Bit Pirate.

Troubleshooting

  • Powering a motor or servo directly from an ESP32 GPIO.
  • Forgetting shared ground with an external servo supply.
  • Leaving a PWM channel attached after testing.
  • Using GPIOs reserved by the current board.

Next steps

  • Use measure on another pin to verify the generated signal.
  • Run reset <gpio> after a test.
  • Use the logic analyzer recipe for waveform confirmation.

PWM and servo signal FAQ

What does this recipe generate for a servo?

It generates the control pulse train expected by hobby servos. Power delivery is a separate bench-wiring decision and should be handled independently from the signal recipe.

How is servo position represented in this workflow?

Servo position is represented by pulse width, usually within the range expected by hobby servos. The recipe is about generating that timing signal, not measuring mechanical position feedback.

When is PWM useful without a servo?

PWM is also useful for testing LED drivers, optocouplers, logic inputs, filters and trigger paths where you only need a repeatable square-wave-like signal.

Go deeper