Hi, I am using and ADJDS-311 Color evaluation sensor board and depending of the color detected move servos, the problem I have is that when I connect the three servos the led of the ADJDS-311 turns on and then off for a while and the servos moves in little steps, hope you can help me, thank you.
#include <Servo.h>
#include <ADJDS311.h>
#include <Wire.h>
int sensorLed_pin = 2; //LED on the ADJDS-311
ADJDS311 colorSensor(sensorLed_pin);
//if using an RGB LED (Needs PWM Pins)
Servo myservo;
Servo myservo2;
Servo myservo3;
void setup(){
Serial.begin(9600);
colorSensor.init();
colorSensor.ledOn(); //turn LED on
myservo.attach(10);
myservo2.attach(8);
myservo3.attach(9);
//Calibrate white
//Need to hold white card in front (1-3mm) of it to calibrate from
colorSensor.calibrate();
}
void loop(){
RGBC color = colorSensor.read(); //read the color
Serial.print(color.red);
Serial.print(" | ");
Serial.print(color.green);
Serial.print(" | ");
Serial.print(color.blue);
Serial.print(" | ");
Serial.println(color.clear);
delay(1100); //just here to slow down the serial output
if(color.red > 980 && color.blue < 340) { // here is color red detected
myservo.write(180);
}
else{
myservo.write(0);
}
if (color.red > 1000 && color.green > 1000 && color.clear < 900){ // yellow
myservo2.write(180);
}
else{
myservo2.write(0);
}
if (color.clear < 270 && color.blue <245){ //green
myservo3.write(180);
}
else{
myservo3.write(0);
}
}