# Arduino Lightsensor Blocking Code

I have a GY-31 Light sensor and I am trying to make a skittle sorting machine. There is a little wheel skittles can drop into then they are turn to 90 degrees read by the light sensor then dropped out the bottom. The problem is the code seems to get stuck after reading the light sensor (it still flows through but won't execute the moving of the servo). As soon as I take out the ReadSensor line the servo works like normal. Do I have to dispose of the Color Sensor some how?

#include <Servo.h>
#include <MD_TCS230.h>
#include <FreqCount.h>

#define  S2_OUT  2
#define  S3_OUT  3
MD_TCS230  CS(S2_OUT, S3_OUT);

Servo myservo;  // create servo object to control a servo
// a maximum of eight servo objects can be created

void setup()
{
myservo.attach(11);  // attaches the servo on pin 9 to the servo object
Serial.begin(57600);
Serial.println("[TCS230 Simple BLOCKING Example]");
Serial.println("Move the sensor to different color to see the 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();
CS.setFilter(TCS230_RGB_X);
CS.setFrequency(TCS230_FREQ_HI);
CS.setSampling(100);
}

{
uint32_t v;
Serial.print("Simple value = ");

}

void loop()
{
Serial.println("Start");
myservo.write(0);
delay(1000);
myservo.write(90);
delay(1000);

• Not related to the problem at hand, but why do you bother with setting v in readSensor() since you never use it? – apnorton Nov 1 '14 at 10:49