Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
09.02.2010 at 18:37:32
News: Server upgrade went fine, you are now at the new system


Pages: 1
How to interface with a phototransistor (Read 2323 times)
RichP
YaBB Newbies
*
Offline

Arduino rocks

Posts: 35

How to interface with a phototransistor
09.02.2009 at 12:12:16
 
Hello all,

I'm new to the world of Arduino and thoroughly enjoying things so far. I decided to go a little further with my experiments, and try hooking up a phototransistor.

The thing I'm a little unclear about though, is exactly how I'd go about hooking that up to the Arduino, and interpreting the output (I just tried to paste a link to the product into this post, but the forum software won't let me do it until I've made 'one normal post', so I'll follow this post up immediately with the link to the sensor!) Smiley

I've done a bit of digging around and I'm not really sure how to go about hooking it up and interpreting the readings with the Arduino just yet.

Would anyone be able to offer some advice/pointers?

Many thanks,

/Rich.
Back to top
 
 
View Profile   IP Logged
RichP
YaBB Newbies
*
Offline

Arduino rocks

Posts: 35

Re: How to interface with a phototransistor
Reply #1 - 09.02.2009 at 12:12:45
 
For reference, this is the sensor that I have purchased:
http://www.maplin.co.uk/module.aspx?moduleno=12709

There is a link to a schematic on the site but it doesn't look particularly clear...
Back to top
 
 
View Profile   IP Logged
roboter
YaBB Newbies
*
Offline

Arduino rocks!

Posts: 28

Re: How to interface with a phototransistor
Reply #2 - 09.02.2009 at 13:38:59
 
I ordered this 1 - still waiting Smiley
Teh Hex Pummer
http://www.solarbotics.com/products/k_hp/
Back to top
 
 
View Profile   IP Logged
Grumpy_Mike
God Member
*****
Offline

Solder is electric
glue

Posts: 5198
Manchester (England England)
Gender: male
Re: How to interface with a phototransistor
Reply #3 - 09.02.2009 at 13:39:13
 
Just looked at the schematic and it is total pants.

Wire up anode to +5v, cathode to a resistor (between 100R and 300R) other end to ground. You should be able to see it glowing if you look at it through a digital camera.

Next the sensor. Emitter to ground, collector to a digital input pin, plus a resistor (about 10K) from that input pin to 5V.

Read the value from the pin, a zero will indicate light is being reflected back, a one indicates no light reflected.
Back to top
 
 
View Profile | WWW   IP Logged
mem
God Member
*****
Online

Have fun!

Posts: 5418
London
Re: How to interface with a phototransistor
Reply #4 - 09.02.2009 at 14:08:29
 
Quote:
Next the sensor. Emitter to ground, collector to a digital input pin, plus a resistor (about 10K) from that input pin to 5V.

Or you can use the internal pull up resistors
You will need to set the pinMode to input anyway:
 pinMode(pin, INPUT);           // set pin to input
if you write a HIGH value after the pin is set for input then the internal pull-up resistor will be connected:
digitalWrite(pin, HIGH);       // turn on pullup resistor
This saves you connecting an external 10k resistor to the pin.

Quote:
You should be able to see it glowing if you look at it through a digital camera.

Nice tip
Back to top
 
 
View Profile   IP Logged
Grumpy_Mike
God Member
*****
Offline

Solder is electric
glue

Posts: 5198
Manchester (England England)
Gender: male
Re: How to interface with a phototransistor
Reply #5 - 09.02.2009 at 14:27:00
 
Hi  mem,
I did think of the internal pull ups but I think you want to pull more current through the photo transistor than they would give. The edges can be a little slow if you don't give them enough current. But in this application he will probably get away with it.
Back to top
 
 
View Profile | WWW   IP Logged
RichP
YaBB Newbies
*
Offline

Arduino rocks

Posts: 35

Re: How to interface with a phototransistor
Reply #6 - 09.02.2009 at 14:34:03
 
Hi all,

The schematic on the Maplin site is indeed - pants. Smiley

Thanks to everyone so far for all your help. I'll give this a go later this evening and post my results.

Again, thanks for the speedy replies!

/Rich
Back to top
 
 
View Profile   IP Logged
RichP
YaBB Newbies
*
Offline

Arduino rocks

Posts: 35

Re: How to interface with a phototransistor
Reply #7 - 09.02.2009 at 16:15:20
 
Hi all,

Ok - bear with me here, new to this.

So I've connected the photoresistor to the breadboard and the arduino. I have verified that the emitter is wired correctly (can see the red light being emitted throuh a digicam - great tip!).

I'm having trouble actually wiring up the sensor correctly.

The sensor is connected as follows:

  GND -- [ SENSOR ] -- Resistor (10k) -- Digital Pin 7

My question is: where do I connect the +5v?

Thanks for your patience and support.

/Rich
Back to top
 
 
View Profile   IP Logged
retrolefty
God Member
*****
Offline

Measurement changes
behavior

Posts: 2471
SF Bay Area (USA)
Re: How to interface with a phototransistor
Reply #8 - 09.02.2009 at 16:38:04
 
Quote:
The sensor is connected as follows:

 GND -- [ SENSOR ] -- Resistor (10k) -- Digital Pin 7

My question is: where do I connect the +5v?

Thanks for your patience and support.

/Rich


Ground should wire to the cathode lead of the photo diode. The anode lead of the diode should wire to the 10k resistor. The other end of the resistor should wire to +5vdc. Digital pin 7 should wire to the junction of the diode anode and 10K resistor.

Lefty
Back to top
 
 
View Profile   IP Logged
Grumpy_Mike
God Member
*****
Offline

Solder is electric
glue

Posts: 5198
Manchester (England England)
Gender: male
Re: How to interface with a phototransistor
Reply #9 - 09.02.2009 at 16:46:58
 
Hi  lefty,
It's not a photo diode he has but a photo transistor.

Quote:
GND -- [ SENSOR ] -- Resistor (10k) -- Digital Pin 7


is not quite right it should be:-
Quote:
GND -- [ SENSOR ] -- Resistor (10k) -- +5v
                             |
                     Digital Pin 7


That is Pin 7 and the sensor and the resistor all together.
Back to top
 
 
View Profile | WWW   IP Logged
RichP
YaBB Newbies
*
Offline

Arduino rocks

Posts: 35

Re: How to interface with a phototransistor
Reply #10 - 09.02.2009 at 17:07:10
 
Hi Grumpy_Mike,

That's exactly what I needed - thank you. Now, when the photo transistor is 'open' the input is HIGH. When it is 'reflecting' the input is LOW. Does that sound about right?

Thanks,

/Rich
Back to top
 
 
View Profile   IP Logged
Grumpy_Mike
God Member
*****
Offline

Solder is electric
glue

Posts: 5198
Manchester (England England)
Gender: male
Re: How to interface with a phototransistor
Reply #11 - 09.02.2009 at 18:04:23
 
Quote:
when the photo transistor is 'open' the input is HIGH. When it is 'reflecting' the input is LOW.


Spot on. Now make it happen.  Wink
Back to top
 
 
View Profile | WWW   IP Logged
Pages: 1