Projectile Launcher
Servo Mechanics
Pan and Tilt
To aim our launcher, we need two degrees of freedom:
- Pan: Moving left and right (Azimuth).
- Tilt: Moving up and down (Elevation).
We use Servos for this because they can hold a specific angle preciseley.
Controlling Servos
In code, we simply tell the servo what angle to go to:
CPP
#include <Servo.h>
Servo panServo;
Servo tiltServo;
void setup() {
panServo.attach(9);
tiltServo.attach(10);
}
void loop() {
panServo.write(90); // Center
tiltServo.write(45); // 45 degrees up
}
Be careful not to push the servos past their physical limits, or you might strip the gears!