Pages: [1]   Go Down
Author Topic: How to interface with a phototransistor  (Read 6127 times)
1 Member and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I ordered this 1 - still waiting smiley
Teh Hex Pummer
http://www.solarbotics.com/products/k_hp/
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33395
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: February 09, 2009, 08:09:05 am by mem » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33395
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: February 09, 2009, 10:15:43 am by brainthings » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33395
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 603
Posts: 33395
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-wink
Logged

Pages: [1]   Go Up
Jump to: