I am trying to control the speed of two servos operating at the same time. Right now they operate at max speed, one counter clockwise, the other clockwise. Code so far is a follows.
const int sensorPin = A0;
int lightLevel = 0;
#include <Servo.h> // servo library
Servo servoFLCW, servoFLCCW; // servo control object
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
servoFLCW.attach(2);
servoFLCCW.attach(3);
}
void loop(){
lightLevel = analogRead(sensorPin);
Serial.print("Light level Bay 1: ");
Serial.println(lightLevel);
if ((lightLevel) > 2);
{
delay(2000);
doorFLCW();
}
}
void doorFLCW() {
if ((lightLevel) < 300) {
servoFLCW.write(135);
servoFLCCW.write(5);
}
else
{
servoFLCW.write(5);
servoFLCCW.write(135);
}
Any constructive help would be appreciated.