Control a Servo From Your Browser — No Driver Code Required | Viam

Build and learn

March 27, 2026

Control a Servo From Your Browser — No Driver Code Required

Wire a micro servo to a Raspberry Pi's GPIO header, configure in Viam, and drive it without custom code.

Adrienne Tacke
Senior Developer Advocate

Jalen Geason
Technical Product Marketing

.png)

What you'll build

You'll wire a micro servo to a Raspberry Pi, configure it as a servo/gpio component in Viam, and use the built-in TEST panel to move it to any angle you want.

What you'll need

Hardware

Software / Accounts

If your machine isn't set up yet, follow the Viam setup guide to get viam-server installed and your machine showing as Live in the app.

Step 1: Wire it up

Your servo has three wires. Connect them to the Raspberry Pi GPIO header using jumper wires:

Tip: You can use any GPIO pin for the signal wire. Our example uses GPIO 17. Just note the physical pin number (11), not the GPIO number (17). You'll need it in the next step.

Step 2: Add your components

Add the board component

Before adding the servo, make sure your Raspberry Pi is configured as a board component. In your machine's CONFIGURE tab:

  1. Click + and select Configuration block
  2. Search for raspberry-pi and select raspberry-pi:rpi4 (or rpi5 if you're on a Pi 5)
  3. Give it a name, e.g. pi
  4. Click Add component

Add the servo component

  1. Click + and select Configuration block
  2. Search for servo and select servo/gpio
  3. Name the component, e.g. gpio-servo
  4. Click Add component
  5. In the JSON configuration panel, add the physical pin number (not GPIO) and the name of the board component:
{
  "pin": "11",
  "board": "pi"
}

Important: Use the physical pin number (11), not the GPIO number (17). The video calls this out explicitly — they're different numbering schemes.

Click Save . Don't forget to save!

Step 3: Move Your Servo

  1. Open the TEST section of your gpio-servo component
  2. GetPosition shows the current angle, updating automatically
  3. Use Quick move (-5° / +5°) to nudge the servo in 5-degree increments
  4. Or type any angle directly into the Desired angle field and click Execute

The servo arm will physically rotate to match the angle you set (up to its max range). And just like that, you're controlling a servo!

What's Next?

Start building at app.viam.com.