problem with tcs230 sensor and servo

Hi, im making a color sorting machine but i ran into some problems with the code.
The machine is suposed to detect colored balls and sort them with the servo at different angles.
the tcs230 is working giving the color reads but the servo isnt moving at all.
this is the code im using with my arduino uno.

#include <MD_TCS230.h>
#include <FreqCount.h>
#include <Servo.h>
Servo myservo;
// Pin definitions
#define S2_OUT 12
#define S3_OUT 13
#define OE_OUT 8 // LOW = ENABLED
MD_TCS230 CS(S2_OUT, S3_OUT, OE_OUT);
void setup()
{
myservo.attach(9);
Serial.begin(57600);
Serial.println("[TCS230 Simple NON_BLOCKING Example]");
Serial.println("\nMove the sensor to different color to see the RGB value");
Serial.println("Note: These values are being read in without sensor calibration");
Serial.println("and are likely to be far from reality");

CS.begin();

}
void readSensor()
{

static bool waiting;

if (!waiting)
{
CS.read();
waiting = true;
}
else
{
if (CS.available())
{
colorData rgb;

CS.getRGB(&rgb);
Serial.print("RGB [");
Serial.print(rgb.value[TCS230_RGB_R]);
Serial.print(",");
Serial.print(rgb.value[TCS230_RGB_G]);
Serial.print(",");
Serial.print(rgb.value[TCS230_RGB_B]);
Serial.println("]");

if (rgb.value[TCS230_RGB_R]<255)
{
myservo.write(45);
delay (300);
}

else
{
if (rgb.value[TCS230_RGB_G]<255)
{
myservo.write(60);
delay (300);
}

else
{
if (rgb.value[TCS230_RGB_B]<255)
{
myservo.write(90);
delay (300);
}

else
{
myservo.write(120);
delay (1000);
}
}
}
waiting = false;
}
}
}
void loop()
{
readSensor();
}

P.D. hope someone can help me =(. greetings from México city

A link to the library would be nice.

Properly posted code (use Tools + Auto Format, first) would, too.

Library in my code repository, link below.

What values are being printed for the rgb color read?

Those if/else blocks are weird. They should be like this

if (this is true)
{
  // do Thing A
}
else if (that is true)
{
  // do Thing B
}
else
{
  // do Thing C
}

How have you wired and powered the servo? Hint you should never power a servo from
Arduino 5V supply.

Thanks for your answers!

I used @marco_c 's library.

When the sensor reads red the value tends to 0
RGB (0,255,255)

When the sensor reads blue the also tends to 0
RGB (255,255,0)
And when the sensor reads green, happens the same
RGB (255,0,255)

I conected the servo to an external power supply.

I'll also test the code with your correction @UKHeliBob.

When the sensor reads red the value tends to 0

What value?

I'll also test the code with your correction @UKHeliBob.

You modified the code. You are then supposed to post it again.

Try adding a Serial.print() statement in each block. Is the correct decision being made?

#include <MD_TCS230.h>
#include <FreqCount.h>
#include <Servo.h>
Servo myservo;
// Pin definitions
#define S2_OUT 12
#define S3_OUT 13
#define OE_OUT 8 // LOW = ENABLED
MD_TCS230 CS(S2_OUT, S3_OUT, OE_OUT);
int pos = 0;
void setup()

{
myservo.attach(9);
Serial.begin(57600);
Serial.println("[TCS230 Simple NON_BLOCKING Example]");
Serial.println("\nMove the sensor to different color to see the RGB value");
Serial.println("Note: These values are being read in without sensor calibration");
Serial.println("and are likely to be far from reality");

CS.begin();

}
void readSensor()
{

static bool waiting;

if (!waiting)
{
CS.read();
waiting = true;
}
else
{
if (CS.available())
{
colorData rgb;

CS.getRGB(&rgb);
Serial.print("RGB [");
Serial.print(rgb.value[TCS230_RGB_R]);
Serial.print(",");
Serial.print(rgb.value[TCS230_RGB_G]);
Serial.print(",");
Serial.print(rgb.value[TCS230_RGB_B]);
Serial.println("]");

waiting = false;

}
colorData rgb;

CS.getRGB(&rgb);
if (rgb.value[TCS230_RGB_R]<100)
{
myservo.write(60);
delay (15);
Serial.print("ahuevo");
}

}
}
void loop()
{
readSensor();
}

This code works, but the servo doesn't move at all; the sketch only skip the servo line, it reads the delay and prints the word.
The sensor is working fine.

You should use code tags for code in your post. That is the # button when you are editing your post.

I have run auto format (as suggested by others) and it is clear that the logic may not be what you expect:

  else
  {
    colorData  rgb;

    if (CS.available())
    {
      CS.getRGB(&rgb);
      Serial.print("RGB [");
      Serial.print(rgb.value[TCS230_RGB_R]);
      Serial.print(",");
      Serial.print(rgb.value[TCS230_RGB_G]);
      Serial.print(",");
      Serial.print(rgb.value[TCS230_RGB_B]);
      Serial.println("]");

      waiting = false;
    }

    CS.getRGB(&rgb);
    if (rgb.value[TCS230_RGB_R]<100)
    {
      myservo.write(60);
      delay (15);
      Serial.print("ahuevo");  
    }
  }

I am pretty sure that the servo movement code should be in the 'if' statement if the color sensor has completed reading, with the Serial.print() statements, not outside it. This is probably not your problem but untidy practice. I have also eliminated the double declare of the rgb variable with one in scope for the else part of the statement.

Also I see no logic to move the servo back to any other position once it has moved the first time, so it will appear to be still.