Servos and ADJDS-311

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);
}
  
}

How are you powering everything?

I am powering it with 4 AA, this will be the problem?

Hi,

Four AA batteries should be fine if they are powering the servos and you have something else powering the Arduino, is this what you are doing amd ae the grounds connected between the two power supplies ?

If not read the two links in my signature for whats happening in your project and how to fix it.

Duane B

rcarduino.blogspot.com

Do the servos move normally when you try a simple test sketch like zoomkat's?

I will try powering it with 2 power sources

Thanks DuaneB it works!