I tried with analog input 5v and ground.
I ask to show with serial port data from sensor:
the value rolls from 1018 1021 and 1022 1023
but i can't understand how can I use this values to determinate if there is an object or not in front of the sensor. data seems a little random.
I put a resistor that links analog input and 5v + the values are changed to 500 510 to 640 700 or something like this, but seems just casual. :-[ :-[
help plzzz
I don't think you need the 100 ohm resistor according to the suggested application on the datasheet. It looks like there is already a resistor in series in side the IC.
Although with the second LED, you may be conducting too much current. How did you wire the second LED? In series? parallel? Series would be a bad idea (not enough current) while parallel might be too much current into pin 4 of the IS471F. I would stick to one LED for now until you get it working.
Your 0.33uF capacitor is too far away from the IC. This "decoupling" capacitor only does any good when its leads are really close to the leads of the IC.
Ok I am next to bed now, 5.49 AM here in Italy >:( >:( >:(
buuut...I want to use this sensor to sense any obstacle in front of my robot. It is not necessary a long range.
The second led connection is in parallel.
Thank you for your adivises!
Tomorrow, uhmm.... today I will put closer the capacitor and I will remove one led line.
Are you sure that I have to remove 100 ohm resistor?
Uhm...
This is not the right forum section but, do you know a good code to test, and eventually calibrate sensors like this?
Thank you again for your help
[ps]
I am still next to bed but i am not on it, this is the second version:
now there is only one led and no resistor
I plug red to 5v black to ground and output to analog3
I get values by 0 to 4 mmm seems random again, or high value low value repetead.
In that last photo your LED and sensor appear to be at right angles. The sensor's detection is the centre of the package, see the data sheet. So you have to arrange the light to bounce off the surface you want to detect and into the sensor.
Check with an electronic camera that the LED is actually lighting up.
Try cupping your hand over the LED and sensor to try and couple light back in.
Looking on the datasheet of IS471F we see that it provides 55mA current for LED. If you have a high power LED I think you just connect one LED directly. Otherwise connect two LEDs in parallel. You do not need the resistor. With 100 Ohm resistor and 55mA current you get 55mA*100 = 5.5V drop on the resistor so it is not enough voltage (5V-5.5V = -0.5V < 1.5V) to power the LED at all! The LED is driven by a transistor (see datasheet) so it takes care of current regulation by itself.
And it is important that the beam from the LED must reflect to the sensor. The point is that both LED and sensor are kind of directed. I played with LEDs/photodiodes yesterday and it is really true!
Ok it works!!
Testing with tester device I obtain 5 volts without obstacle in front, and 0,1 0 volt with 10 / 15 cm far away obstacle. It's seems like a button, there is not middle values, but if you use it like a bumper I think it's good.
How can I say to arduino that 0,1 0 volt are LOW and 5 volt are HIGH?
With 100 Ohm resistor and 55mA current you get 55mA*100 = 5.5V drop on the resistor so it is not enough voltage (5V-5.5V = -0.5V < 1.5V) to power the LED at all!
Ohms law doesn't work like that. The current will drop to the value given by the voltage and the resistance. There will still be enough voltage to turn the LED on but the current it will take will be smaller. Assuming there is 2V across the LED when it is on that gives 3V across the resistor. And so the current will be 3 / 100 = 30mA.
How can I say to arduino that 0,1 0 volt are LOW and 5 volt are HIGH?
If you are feeding it into a digital input you can't. If you are feeding it into an analogue input then just use and if() statement:-
val = analogRead(0);
if( val > 900) val = HIGH; else val = LOW;
#include <Servo.h>
int inPin = 12; // choose the input pin (for a pushbutton)
int irinput = 3;
int val = 0; // variable for reading the pin status
int valir = 0;
Servo left;
Servo right;
boolean status;
void setup() {
Serial.begin(9600);
//pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input
pinMode(irinput, INPUT);
left.attach(9);
right.attach(10);
status = true;
}
void loop(){
valir = analogRead(irinput); // read input value
if (valir > 900) { // check if the input is HIGH (button released)
left.write(180);
right.write(0);
status = false;
} else {
left.write(0); // turn back
right.write(180);
delay(750);
left.write(0); // turn back
right.write(90);
delay(1000);
}
}
This is a test code for a little robot.
The sensor can feel objects 15 18 cm far depending on surface and color with an angle of 35° 40°.
Very good efficency low price.
Thank you guys