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**  
- Raspberry Pi 4 (or Pi 5)  
- Micro servo (e.g. SG90 or similar 3-wire hobby servo)  
- Male-to-female jumper wires (3)

**Software / Accounts**  
- [Viam account](https://app.viam.com/)  
- viam-server installed and running on your Pi

If your machine isn't set up yet, follow the [Viam setup guide](https://docs.viam.com/operate/install/setup/) 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:

- Red (Power) → **5V** (Physical pin 2 or 4)  
- Brown/Black (Ground) → **GND** (Physical pin 6, 9, or 14)  
- Orange/Yellow (Signal) → **GPIO 17** (Physical pin 11)

**_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:

```json
{
  "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?

- **Fine-tune behavior** — Set min_angle_deg, max_angle_deg, and frequency_hz in your [servo/gpio config](https://docs.viam.com/operate/reference/components/servo/gpio/) to match your servo's datasheet
- **Control with code** — Use the Viam [Python SDK](https://python.viam.dev/autoapi/viam/components/servo/) or [Go SDK](https://docs.viam.com/sdks/go/) to move the servo programmatically
- **Add data capture** — Log servo positions over time with [Viam data management](https://docs.viam.com/data/)  
- **Trigger on events** — Use [Event Manager](https://app.viam.com/module/viam/event-manager) to move the servo in response to sensor readings

Start building at [app.viam.com](https://app.viam.com/).
