Back

Project 4 Balance Beam

divider

Task 1: Circuit

Required components:
  • (1) Potentiometer
  • (1) Servo Motor
Balance Beam Circuit

Task 2: Code

balance_beam.ino
#include<Servo.h>
Servo myServo;
int potVal;
int anglePosition;
void setup() {
myServo.attach(9);
}
void loop() {
potVal = analogRead(A0);
anglePosition = map(potVal, 0, 1023, 10, 170);
myServo.write(anglePosition);
delay(20);
}
divider

Project Complete