I want to send IR light from an IR transmitter ("clear-transparent" LED) to an IR receiver ("black" LED) and when the IR link is disconnected from an object to give me a signal. Both LEDs have two pins (anode,cathode). I will connect the transmitter to +5Volts and the GND so that it continuously sends light. I will connect the the receiver to the GND and the pin 2 of the Arduino to sense when I have +5Volts and when I have 0Volts. Should I use any PULL_UP resistors of the Arduino? What resistors should I use?
I use 220 Ohms resistors (the pots).
I use these elements:
L53F3C
and
L53P3BT
The code I use is this:
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
Serial.begin(9600);
}
void loop() {
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
Serial.println(val);
delay(2000);
}
I have connected the above circuit to a bigger circuit/project that it was for. I use the code below:
void setup() {
Serial.begin(9600); // setup serial
}
void loop() {
Serial.println(analogRead(A0)); // debug value
delay(2000);
}
in order to detect when there is an object cut the IR beam or not. The problem is that although the first time I was getting >1000 when there was an object and <600 when there was not an object. Now I get: