LED and photoresistor

Hello Fellow Arduino-Lovers

I have the following problem i got a photoresistor and 2 LED's; one LED is supposed to be on when the photoresistor isn't blocked. i want the other LED to be on when the photoresistor is blocked. after some time of searching i didn't even find a hint how my code hast to look like to realize this special kind of setup

here is the code i'm using now and which is working for one LED being on while the photoresistor isn't blocked

int lightPin = 0; int ledPin=8; int ledPin=9;

void setup() { Serial.begin(9600); pinMode( ledPin, OUTPUT ); }

void loop() { Serial.println(analogRead(lightPin)); analogWrite(ledPin, analogRead(lightPin)/2); delay(10); }

hope u guuys can help me =)

best wishes SheepRusH

P.S.: I'm using the Arduino UNO

I haven't really programmed the arduino yet, so some arduino function calls may be wrong, but I think you want something like:

int lightPin = 0;
int ledPin0=8;
int ledPin1=9;

void setup()
    pinMode( ledPin0, OUTPUT );
    pinMode( ledPin1, OUTPUT );
    pinMode( lightPin, INPUT );

void loop()
    if (analogRead(lightPin)) {
          digitalWrite(ledPin0, HIGH);
          digitalWrite(ledPin1, LOW); 
    } else {
          digitalWrite(ledPin1, HIGH);
          digitalWrite(ledPin0, LOW); 


The original code will be “true” unless the sensor is in the very very dark (or light, depends on your circuit)
if (analogRead(lightPin)) {should be

if (analogRead(lightPin) > 500) {

Pick any value between 1 and 1023 to be the trigger value.
(If you are not using Serial. elsewhere in the code then you do not need the Serial.begin in the setup)

i wanna thank u =) now it does work as i wished

best wishes

I have trouble code LED and photodiode in Arduino, if anyone can help me about the LED and photodiode?

sample code in Arduino LED and photodioda ... thanks