Optical Sensor Problem Doesnt Send Output

Hello Community

Im working with an optical sensor, build the circuit and try to use it with the following code

/*

  • ap_ReadDigital
  • Reads an digital input from the input pin and sends the value
  • followed by a line break over the serial port.
  • This file is part of the Arduino meets Processing Project.
  • For more information visit http://www.arduino.cc.
  • copyleft 2005 by Melvin Ochsmann for Malmö University

*/

// variables for input pin and control LED
int digitalInput = 7;
int LEDpin = 13;

// variable to store the value
int value = 0;

void setup(){

// declaration pin modes
pinMode(digitalInput, INPUT);
pinMode(LEDpin, OUTPUT);

// begin sending over serial port
beginSerial(9600);
}

void loop(){
// read the value on digital input
value = digitalRead(digitalInput);

// write this value to the control LED pin
digitalWrite(LEDpin, value);

// if value is high then send the letter 'H' else send 'L' for low
if (value) serialWrite('H');
else
serialWrite('L');

// wait a bit to not overload the port
delay(10);
}

But when I intersect the sensor with an object doesnt work. I mean the data printing is always L continously I had try also the button example that goes with arduino but the same thing happen and the led is always on

Does anyone could help me.
These URL have images to explain graphical form the problem

http://www.seco.xl/circuito.zip

thanks,
IN

hi

the link doesn't work...

D

For the sake of debugging, try println(value); to see what's coming off the sensor, increase the delay a little so it doesn't spin out. Then open the serial monitor in the Arduino IDE and see what it's up to.

Sorry Guys

Here is the correct URL

www.secox.cl/circuito.zip

I change the delay up to 100 but he same thing happen. Only the L was printed continously

Please check the images I think that the circuit is build ok, but maybe something Is missing.

IN

hi

nice pictures! IT always makes it so much easier to see the problem.

Do you have a voltmeter? what is the voltage between the + on the D-side and ground when you break the path?

D

Dear Daniel

Sorry for the delay but I dont have a tester so I have to wait for a friend and work on these during the weekend. The volt between the + on the D-side and ground is 5V when I break the path.

I change the GND to 5V and try breaking the path but the samething happen

Before I made the test on the protoboard, we saw a bending circuit that has a Transistor NPN (PN2222A) a LED three resistors (one of 1,5, other of 330 Ohms. and 1 KiloOhms) and it works.

The diagram, the datasheet of the Transistor and the photos of the bending circuit are on the following URL:

www.secox.cl/circuito2.zip

So I think that the circuit is bad made. But I dont know what is the real problem. Any idea?

Thank you,

IN

Hi Ignacio:

i couldn't really tell what is going on in your diagram... My guess is maybe you burned out the transistor if you tried a bunch of wiring configurations.

I was working in Eagle when I read your post, so I made a diagrma and uploaded it. this is how you should wire it;
Look under "slot detectors"
http://www.arduino.cc/playground/Learning/Tutorials

Daniel

Hi Ignacio,

see my reply to Bárbara, here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1189093125/2#2

/jorge

Hi Daniel,

Looking at the diagram you've just uploaded of the slot detector, don't you think that the output to the Arduino pin will always be +5V?

With this diagram, when the transistor is OFF the output will still be +5v. If I understand correctly...

I believe that's the problem with Ignacio's circuit.

/jorge

hi jorge,

the diagram is not perfect,as I used the symbol for an optoisolator, a close cousin of the slot detector, so you don't see the 'slot' represented between transistor and led.

It's still electrically correct though:

  • with no led light on the transistor, its C-E junction is 'open', and the collector will be at 5V.
  • with led light on the transistor, it will conduct and its collector will drop to about .7V, the standard C-E voltage drop for a saturated transistor.

Does that sound right to you?

D

Hi Daniel,

Yes, it sounds right... :slight_smile: Basic stuff.

And Ignacio's circuit seems to be OK.

Keep up the good work.

cheers,

/jorge

Dear Daniel and Jorge

I have try the slot connector but doesnt work I try differents conncetcions with the ap_ReadDigital adn Button applications.
See images www.secox.cl/circuito3.zip

I think the circuits of circuito2 and circuito zip files are well done. But here is something wrong. Do I need other electronic component?

I put in contact with Barbara to mantain one post of the theme.

Greetings from Santiago, Chile

IN

HI Igancio:

I think your sensor is burned, try another.

D

What is the sensor that you're using? Exactly the reference, because I want to made a similar idea.
Thnaks.

the links don't work...please, i wnat to check them
thanks