Back

Bonus Project: Servo Turret

Difficulty  

Optional — Extra Credit

divider

What This Is

A servo that aims where you point it. Turn the knob, the turret swings. Add a launcher if you want one.

The servo is the one part of the kit the scheduled activities never touch, and this is where it lives. Aiming is the whole project; launching is optional and considerably messier.

divider

What You'll Need

  • The sub-micro servo
  • The potentiometer, on an analog pin
  • Something light to aim — a craft stick, a cardboard arrow, a paper cone
  • A paper arc on the desk with marked targets

A servo needs three connections: power, ground, and one signal pin. Power it from 5V if your servo stalls or twitches on 3V3 — unlike the sensors, a servo is a motor and wants the current.

divider

Build It

  1. Make it move at all. A servo is driven by PWM at about 50Hz. Find two duty values that give you two clearly different positions, and write them down.
  2. Write set_angle(servo, angle) so the rest of your program can ask for a direction instead of a duty cycle. Work out the arithmetic from your two known positions.
  3. Sweep it end to end, so you know its real range. It will not be a full 180°.
  4. Map the knob onto the angle using the scaling you wrote in Activity 2.8 — the same shape, a different output range.
  5. Aim at marked targets and read the angle off the screen or terminal as you go.

Task 2 is the interesting one. Everything else in this unit handed you the conversion; here you have two measured points and have to build the rule yourself.

divider

Then Make It Yours

  • Add a second axis. A pan-and-tilt bracket plus a second servo and a second knob. Aim in two directions.
  • Add a launcher. A servo can release stored energy but cannot store it — it can pull a catch that lets a tensioned rubber band go, but it cannot prime one. Expect one shot per hand-reload.
  • Aim automatically. Sweep the servo, read the ultrasonic sensor at each step, and stop where something is closest.
divider

If You Build a Launcher

  • Rubber bands and paper only. Nothing hard, nothing heavy, nothing sharp.
  • Aim at a wall or a target, never at a person, and never at head height.
  • Ask before you fire it in the room.

Commence Project