RGB and LightSensor Code

Hi,
I was trying to get Arduino to turn on the light as green when it is exposed to light, then after 10 seconds to turn blue, and after 5 seconds to turn red. I figured that the best way would be to use a rgb led. I have done that, and added the light sensor. The problem I am having is that I cant get the light sensor code to work. Also, the light that first comes up is green, but rather blue. Here is the code I am using:
int LEDGreen = 10;
int LEDPurple = 9;
int LEDRed = 11;
int lightLevel = 0;
int counter = 0;
int lightPin = 12;
void setup ()
{
pinMode(LEDGreen, OUTPUT);
pinMode(LEDPurple , OUTPUT);
pinMode(LEDRed, OUTPUT);
pinMode (lightPin, OUTPUT);
}
void loop()
{
lightLevel = analogRead (lightPin);
if (lightLevel > 500);
{
counter = counter + 1;
}
if (counter = 10)
{
digitalWrite (lightPin, HIGH);
}
delay (1000);
setColor(255, 0, 0); // red
delay(15000);
setColor(0, 255, 0); // green
delay(5000);
setColor(255, 255, 0); // yellow
delay(10000);

}

void setColor(int green, int purple, int red)
{
analogWrite(LEDGreen, green);
analogWrite(LEDPurple, purple);
analogWrite(LEDRed, red);
}

Please let me know what I am doing wrong. Thank you

if (lightLevel > 500);

Lose the semicolon

if (counter = 10)

Lose the assignment

I am sorry, but what does lose assignment mean...i have deleted the semi colon, but could not understand what assignment meant..thanks

if(counter = 10)

Is an assignment, but if (counter == 10) is a comparison.

Thank you...
I have updated my code, and I have gotten the colours to work properly, the only issue I am having now is that when I add the light sensor, it tells me that the redefinition of void setup...
int greenPin = 11;
int bluePin = 10;
int redPin = 9;

void setup()
{
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin, OUTPUT);
}

void loop()
{

setColor(0, 255, 0); // green
delay(5000);
setColor(0, 0, 255); // blue
delay(10000);
setColor(255, 0, 0); // red
delay(15000);

}

void setColor(int green, int blue, int red)
{
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
analogWrite(redPin, red);
}

int LDR = 2;
int LEDGreen = 11;
int LEDBlue = 10;
int LEDRed = 9; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor

void setup() {
pinMode(LDR, INPUT); // declare the LDR as an INPUT
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin, OUTPUT); // declare the ledPin as an OUTPUT
}

void loop() {
if (val = 600); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
}

f (val = 600); Still the assignment, still the semicolon.
And two "loop"s are not allowed.

ok, I have tried to incorporate the light sensor with the rgb, but it still doesnt work... i have made a new code... please let me know what is wrong, thank you very much..I have added the assignment

int lightPin = 0; //PhotoResistor Pin
int greenPin = 11;
int bluePin = 10;
int redPin = 9;

boolean sensorState = false;

void setup()
{
pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT);

pinMode(redPin, OUTPUT);

}
void digitalWrite ()
{

pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin, OUTPUT); //sets the led pin to output
digitalWrite(greenPin, HIGH); //turns on led
digitalWrite(bluePin,HIGH);
digitalWrite(redPin,HIGH);
Serial.begin(9600);
}

void loop()
{
setColor(0, 255, 0); // green

delay(5000);

setColor(0, 0, 255); // blue

delay(10000);

setColor(255, 0, 0); // red

delay(15000);

}

void setColor(int green, int blue, int red)

{

analogWrite(greenPin, green);

analogWrite(bluePin, blue);

analogWrite(redPin, red);

}
void analogRead()
{
int threshold = 300;
if (analogRead(lightPin) > threshold && sensorState == true)

{
Serial.println("sensor blocked");
sensorState = false;
delay(50);

}
else
if(sensorState == false)
Serial.println("sensor open");
}

void digitalWrite ()

Arduino already has function called digitalWrite, so it'll get upset when you try to define another.
Ditto analogRead.

ok, I did exactly what you told me to do, I deleted the digitalWrite and the analogRead, and the light sensor is still not working.

OK, so post your code - I can't imagine what it looks like now.
Use code tags this time.

Thank you soo much for helping. Here is the code:

int lightPin = 0; //PhotoResistor Pin
int greenPin = 11;
int bluePin = 10;
int redPin = 9;

boolean sensorState = false;

void setup()
{
pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT);

pinMode(redPin, OUTPUT);

}
void digitalWrite ()
{

pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin, OUTPUT); //sets the led pin to output
digitalWrite(greenPin, HIGH); //turns on led
digitalWrite(bluePin,HIGH);
digitalWrite(redPin,HIGH);
Serial.begin(9600);
}

void loop()
{
setColor(0, 255, 0); // green

delay(5000);

setColor(0, 0, 255); // blue

delay(10000);

setColor(255, 0, 0); // red

delay(15000);


}


void setColor(int green, int blue, int red)

{

analogWrite(greenPin, green);

analogWrite(bluePin, blue);

analogWrite(redPin, red);



{
int threshold = 300;
if (analogRead(lightPin) > threshold && sensorState == true)

{
Serial.println("sensor blocked");
sensorState = false;
delay(50);
{
}
}
else
if(sensorState == false)
Serial.println("sensor open");
}
}

You've still defined a function called digitalWrite.
So has the Arduino.

I removed that one, uploaded it on my arduino breadboard, and it still doesnt work.. here is my code

int lightPin = 0; //PhotoResistor Pin
int greenPin = 11;
int bluePin = 10;
int redPin = 9;

boolean sensorState = false;

void setup()

{  
pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT);

pinMode(redPin, OUTPUT);


pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin, OUTPUT); //sets the led pin to output
digitalWrite(greenPin, HIGH); //turns on led
digitalWrite(bluePin,HIGH);
digitalWrite(redPin,HIGH);
Serial.begin(9600);
}

void loop()
{
setColor(0, 255, 0); // green

delay(5000);

setColor(0, 0, 255); // blue

delay(10000);

setColor(255, 0, 0); // red

delay(15000);


}


void setColor(int green, int blue, int red)

{

analogWrite(greenPin, green);

analogWrite(bluePin, blue);

analogWrite(redPin, red);



{
int threshold = 300;
if (analogRead(lightPin) > threshold && sensorState == true)

{
Serial.println("sensor blocked");
sensorState = false;
delay(50);
{
}
}
else
if(sensorState == false)
Serial.println("sensor open");
}
}

and it still doesnt work

Define "work"

Look at the initial values of your variables, and how your code might vary them

Maybe think about using auto format before posting code next time

Your code cleaned up and in a compilable and consistent form where comments match function definitions.

int lightPin    =  0;   //PhotoResistor Pin

int greenPin    = 11;
int bluePin     = 10;
int redPin      =  9;

boolean sensorState = false;

void setup()
{
    Serial.begin(9600);

    pinMode(greenPin, OUTPUT);
    pinMode(bluePin, OUTPUT);
    pinMode(redPin, OUTPUT);

    digitalWrite(greenPin, HIGH);
    digitalWrite(bluePin,  HIGH);
    digitalWrite(redPin, HIGH);
}

void loop()
{
    setColor(0, 255, 0);    // green
    delay(5000);

    setColor(0, 0, 255);    // blue
    delay(10000);

    setColor(255, 0, 0);    // red
    delay(15000);
}


void setColor(int red, int green, int blue)
{
    analogWrite(redPin, red);
    analogWrite(greenPin, green);
    analogWrite(bluePin, blue);

    int threshold = 300;
    if ( (sensorState == true) && (analogRead(lightPin) > threshold) )
    {
        Serial.println("sensor blocked");

        sensorState = false;
        delay(50);
    }
    else if ( sensorState == false )
    {
        Serial.println("sensor open");
    }
}