TINKER PiEDESIGN IN INDIA

Make a servo sweepTinkerPieCircuit tutorial 12 of 24 · Beginner · 10 minutes

Connect a servo motor to power and a signal pin and sweep it from 0 to 180 degrees.

Open this circuit in TinkerPieCircuit (free, runs in your browser)

What you will learn

Parts

TinkerPie V1 board1 servo motor

Steps

  1. Add the servo

    Click Servo motor. It has three wires: G (brown), V (red) and SIG (orange).

  2. Wire the power

    Wire G to GND and V to 5V. Servos need more power than a pin can give.

  3. Wire the signal

    Wire SIG to S1. The signal tells the servo which angle to go to.

  4. Sweep with a loop

    A for loop counts from 0 to 180 in steps of 10 and calls servoWrite(S1, a) each time.

  5. Press Start

    The horn of the servo turns and the label shows the angle. If the label says no power, check the V and G wires.

The code

function loop() {
  for (let a = 0; a <= 180; a += 10) {
    servoWrite(S1, a);
    delay(40);
  }
  for (let a = 180; a >= 0; a -= 10) {
    servoWrite(S1, a);
    delay(40);
  }
}

Copy this into the Code tab. It is Arduino-style JavaScript. The real board uses the same pin names (S1, P10…) in TinkerPie Studio.

How it works

The signal pin sends short pulses. The length of each pulse tells the servo the angle. TinkerPie handles the pulses for you.

Challenge: Make it sweep slowly, then quickly. Then move it to exactly 90 degrees and keep it there.

← Build a night light · All 24 circuit tutorials · Play a melody with a buzzer →