Shop OBEX P1 Docs P2 Docs Learn Events
Coding Help/Question — Parallax Forums

Coding Help/Question

G27ViperG27Viper Posts: 6
edited 2008-07-19 23:25 in BASIC Stamp
I have a super carrier board with a BS2 Module...
I have a phototransistor with an op-amp hooked up to pin5...

i want pin5 to be an input pin and when light goes through
the phototransistor i want pin6(output) to go high.

How could I Make this happen?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-19 23:25
    If you want any questions answered about the phototransistor and the op-amp, you'll have to post a schematic.

    All Stamp I/O pins are input by default. They usually have a threshold of somewhere between 0.8V and 2.0V. Anything above 2V is guaranteed to be seen as a logic high (1). Anything below 0.8V is guaranteed to be seen as a logic low (0). If you have the op-amp setup to provide an output above 2V and below 5V when the phototransistor is triggered, then you'll be ok.

    If the op-amp is connected to I/O pin 5, then the variable IN5 will be 1 when the phototransistor is on and 0 otherwise.

    To make I/O pin 6 be an output, you have to execute "LOW 6" somewhere in the initialization portion of your program. This will make the I/O pin an output and set it to logic low (0).

    To copy the state of I/O pin 5 to I/O pin 6, a "OUT6 = IN5" will update pin 6 every time it's executed. You have to put this in a loop to update pin 6 continually. See the Basic Stamp Manual or the "What's a Microcontroller?" tutorial for examples.
Sign In or Register to comment.