Shop OBEX P1 Docs P2 Docs Learn Events
Best way to Connect Phototransistor using 1 pin to propeller — Parallax Forums

Best way to Connect Phototransistor using 1 pin to propeller

Igor_RastIgor_Rast Posts: 357
edited 2012-12-28 10:14 in Propeller 1
Hi there .
I was wondering ,

whats the best way to connect (schematic) the phototransistor to the propeller , and be able to get the difference in lights on or lights off in a room ,
so i wanna be able to detect if its dark in the room , or if there are any lights on , (on/off)
and only 1 pin available , maybe some other parts ( transistor , opamp ) included but 1 pin cause the other pins are ocupied

been reading some , but cant realy get a usefull schematic that the prop can read .
hope to get some help here
any advice ?

Comments

  • Mike GMike G Posts: 2,702
    edited 2012-12-23 13:51
    See forum sticky Propeller Education Kit Labs, Tools, and Applications Measure Resistance and Capacitance for source code and detailed explanations.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-12-23 13:59
    Thanks for pointing me in the right direction Mike .
    im gonna take a look

    does a long wire say 3-5 meter have a bad working on the thing making it respond bad ?
  • Mike GMike G Posts: 2,702
    edited 2012-12-23 14:40
    does a long wire say 3-5 meter have a bad working on the thing making it respond bad ?
    The link explains how to calculate Resistance with a known value of Capacitance. Yes, a 3-5 meter wire will affect the results.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-12-23 16:27
    I was thinking of some schematic That sends back a digital high or low, depending on lights on or off.
    The phototransistor ,a resistor maybe also a variable resistor (fine tunning), a transistor that wil be used as a switch . And some ic to use as buffer for the logic 1 or 0. (Some ic = opamp /inverter orso).
    Found some schematics but can't get a good working example .
    A schematic tha sends back a good result independed of what wire lengt is used is what the goal is
    Hope I can get some useful schematics
  • kwinnkwinn Posts: 8,697
    edited 2012-12-23 19:40
    The first post says "photoresistor" but the link is for a phototransistor. Which one is it? Post the part number.

    Almost any comparator or op amp would do what you want, but we need to know what part you are using to provide a circuit.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-12-24 02:12
    O sorry , its the phototransistor of parallax, I have bought it from parallax some time ago so its identical to the link in the first post .
    did write the wrong name before , have changed it now
    thanks
  • kwinnkwinn Posts: 8,697
    edited 2012-12-24 14:29
    Circuit A would work if the light sensor was on or very close to the propeller board. Circuit B increases the signal current to compensate for any noise the cable might pick up. A twisted pair is recommended. You will need to do some testing with a potentiometer to find the best value for Rx. Any small signal NPN transistor such as 2N3904 or 2N2222 can be used.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-12-27 04:40
    that doenst look bad , ill be trying some of them out there days , it will have to be incorporated with a co2 sensor that I started a new tread about.
    anyway

    the variable resistor sould be on the sensor side , and not on the propside., so ill have to do something else with it ,

    but it a good start so thanks for the schematic.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-12-27 08:57
    You could use an LED as the dark Detector.

    DarkDetector.png


    The higher current or brighter LEDs work best but they all do this.

    Duane J
    408 x 430 - 8K
  • jmgjmg Posts: 15,173
    edited 2012-12-27 12:03
    Igor_Rast wrote: »
    and be able to get the difference in lights on or lights off in a room ,
    so i wanna be able to detect if its dark in the room , or if there are any lights on , (on/off)

    It depends on the room, and other light sources.
    Simple black-out on/off can use almost any sensor with a high value load resistor.

    Where it gets tricky, is if other light sources (like windows) can illuminate the room, and the type of .light bulb.
    This can give highly variable light levels, and you need to sense the 'lights on or lights off " with other light.
    So a simple Digital threshold design, may not be up to practical use.

    CFL/LED lamps may allow you to use a mains-frequency filter, to better decide on internal/external light.
    ( There is some light modulation even on incandescent bulbs, so that may be enough )

    For wide dynamic range, devices like this Light to Frequency Converter are great
    https://www.sparkfun.com/products/9768
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-12-28 10:14
    jmg,

    'No need to point to Sparkfun. Parallax carries these, too (in two different sensitivity ranges):

    -Phil
Sign In or Register to comment.