2. Arduino‎ > ‎

3. Connect a phototransistor to Arduino

After serial link was up. I wanted to add my "IR Detection circuit" to the arduino.
It wasn't really difficult. The schematic below will do:
I used 10k resistor.

After connecting photoresistor, I wanted to see the change in values at Analog 1. This is where Serial Communication comes handy, I can use it to print the values of Analog 1 in a continuous loop so I can see what difference is there when I bring an IR LED in front of this sensor.

I used following code:

int val;



void setup()

{

Serial.begin(9600); // sets the serial port to 9600

}

void loop()

{

val = analogRead(0); // read analog input pin 0


Serial.print(val); // prints the value read

Serial.print(" "); // prints a space between the numbers

delay(10); // wait 10ms for next reading

}

Connect serial link and see if you can capture any readings through Serial Monitor.
Now bring a TV remote and press a button to see if you find any change in the readings.
Play with it!

Comments