- The breadboard assembly was not so difficult. On the first try, I used a photocell as the input. (figure 1)
figure 1 - Here’s the code:
#include <Servo.h>Servo servoMotor;
int servoPin = 3;void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
servoMotor.attach(servoPin);
}void loop() {
//put your main code here, to run repeatedly:
int analogValue = analogRead(A0);
Serial.println(analogValue);
int servoAngle = map(analogValue, 700, 900, 0, 179);servoMotor.write(servoAngle);
Serial.println(servoAngle);}
- The servo does not turn. I checked the serial monitor to see if the photocell is working. Photocell is working. (video 1)
- Then I tried it with an FSR. (figure 2) The servo still did not work.
figure 2 - I suspected it was because the volts output is not enough to drive the servo motor. As a wild guess, I tried to power the servo through two AA batteries. Still didn’t work. (figure 3)
figure 3*update after class on Thursday, July 22, it is because of the lack of voltage.
Leave a Reply