Fototransitor help

Hi, Im getting really desperate.

I have till tomorrow afetrnoon to get this up and running or I will be in serious trouble.
As a project for university I proposed myself using Arduino but I've got into some real challenge.

Not having programming experience this comes very hard.

I have the following schematic mounted:

I need code to make the ligth led works or not depoending on if the fototransitor senses change in the ir reflected light.

Sorry, but plz I really need this.

Thanks for reading

Have you tried to run the analoginput example sketch? (its on the IDe meny : files->sketchbook->Examples->Analog->analoginput)

you need to ensure that the analog pin is the one that your phototransistor is connected to. The sketch uses the led conencted to pin 13, change the sketch if you want to light an lED on a different pin.

That example sets a delay based on the analog value, I think you want to turn the LED on or
off based on the value.

You may want to put a statement like Serial.print(val) after the analogRead so that you can see how the value changes under different lighting conditions (see the communication example and tutorial if you need help getting that going)

Anyway, if you test the value of val after the analogRead you can turn on or off your LED.

int threshold = 512; // you may need to adjust this value
int ledPin = 13; // set this for your led

void loop() {
val = analogRead(potPin); // read the value from the sensor
if( val > threshold)
digitalWrite(ledPin, HIGH); // turn the ledPin on
digitalWrite(ledPin, LOW); // turn the ledPin off