Color change RGB led based on photoresitor

I am trying to create a program in which a photoresistor controls a RGB led, changing the color of it depending on the light sensor value. Here is the code I have so far, but I don't know what to do about the bugs in it, any ideas?

--Here is the code :

const int RED_LED_PIN = 9; //Red LED Pin

const int GREEN_LED_PIN = 10; //Green LED Pin

const int BLUE_LED_PIN = 11; //Blue LED Pin

int lightPin = 0;

void setup() {

}

void loop() {
int lightLevel = analogRead(lightPin);

int redValue = constrain(map(lightLevel, 0, 512, 255, 0),0,255); //calculate the red Value (255-0 over the range 0-512)

int greenValue = constrain(map(lightLevel, 0, 512, 0, 255),0,255);

int blueValue = constrain(map(lightLevel, 512, 1023, 0, 255),0,255); //calculate the blue value 0-255 over 512-1023

lightLevel = map(lightLevel, 0, 900, 0, 255);
//adjust the value 0 to 900 to
//span 0 to 255

lightLevel = constrain(lightLevel, 0, 255);//make sure the
//value is betwween
//0 and 255
analogRead(lightLevel,lightPin)
{if (analogRead(lightLevel)) = map(lightLevel, 1, 99); // Display the requested color
analogWrite(RED_LED_PIN, redValue);
if(analogRead(lightLevel) map(lightLevel, 100,174 ));
analogWrite(GREEN_LED_PIN, greenValue);
if(analogRead(lightLevel) map(lightLevel, 175, 254));
analogWrite(BLUE_LED_PIN, blueValue);}

}

Here is the code I have so far, but I don't know what to do about the bugs in it, any ideas?

...

analogRead(lightLevel,lightPin)
{if (analogRead(lightLevel)) = map(lightLevel, 1, 99); // Display the requested color
analogWrite(RED_LED_PIN, redValue);
if(analogRead(lightLevel)  map(lightLevel, 100,174 ));
analogWrite(GREEN_LED_PIN, greenValue);
if(analogRead(lightLevel)  map(lightLevel, 175, 254));
analogWrite(BLUE_LED_PIN, blueValue);}

First load the program in the GUI and press the compile button. In the lower window, you'll get some red text telling you that the compiler gave up at the first line I quoted. The text I get is:

35: error: expected `;' before '{' token

So what could be the problem? Perhaps that you don't have a ; terminating the line? Adding one will fix that, although it won't resolve your problem. The whole block I quoted is just syntactical garbage. Delete it and rewrite it step by step, compiling and testing it (with Serial.println if you have no other way to see what your program does) after adding each new statement. And while rewriting it, look up in the manual how to properly write an if-statement. You know, programming doesn't involve puking random characters into a file in the hope some jinn will magically arrange things in a working manner.

Korman

if (analogRead(lightLevel)) = map(lightLevel, 1, 99);

That line doesn't make a great deal of sense.
If you added comments, you might give us a clue what you intended to do.
(and I also think you don't want that terminating semi-colon)

As an experienced programmer, I rarely embed a function call in a place where a value is expected.

int greenValue = constrain(map(lightLevel, 0, 512, 0, 255),0,255);

As a newbie, which you appear to be, not even being able to count the number of arguments a function requires, you should not be doing this. There is no way to verify that map() is performing the way you expect it to.

Put each function call on a separate line, and store the output of that function in its own local variable. Pass that variable where the function call is currently used.

When your program does not work as expected, after you get it to compile, you can add Serial.print() statements to show the output of the functions, until you understand what is happening.

Thanks for the help, I finally figured the problem out and fixed it, and yes I am a newbie.

--Gifer