I'm doing a walking robot with turn right or left when an object is detected, i'm using Basic Stamp 2 as software. Can any one give an idea or concept that how i'm gonna to program the sensor part.....
Depends on the type of optical sensor. If it is a phototransistor that provides a high/low signal it is relatively simple. If the signal is high take one action, if the signal is low take the other action. An IR imaging chip requires a more complex program.
Most phototransistors are NPN, not PNP. Unless you meant plug & pray...
The BoeBot text shows pretty clearly how to make a more reliable object detector using an IR LED and a 38 kHz IR rcvr module. Scribbler gets left & right detection using one center mounted detector and 2 LEDs, one left one right.
The thing about phototransistors is that it doesn't matter whether they're constructed as PNPs or NPNs, since there's no base connection. Both types would function exactly the same.
@PhiPi: Did I fail to mention that I was speaking only about metric, left-handed, Australian, region 13 PNP phototransistors? What with the corriolis, reversed seasons and sunspot activity, strange things have been know to happen down under!
Seriously, thanks for your input. I have seen a few Fairchild metal-can phototransistors that do have an unused base lead. It's just there for moral support!
Not sure, but I use them for mechanical fastening & accurate aiming. The FPT540A's I used had nice glass lenses that made them very directional, and they were much more rigid with the base wire soldered to an isolated PC board pad.
IF (Left_sensor = 0) THEN
GOSUB turn
ELSE
GOSUB forward
ENDIF
GOTO main
i wonder my robot dint get into ' turn ' command, and the sensor red LED just keep blinking when ther's an object in front of my robot, the LED should be a permanent light up when ther's an object, is'nt it ?
The specs for your sensor module show 2 differences from the stock BoeBot sensor:
1) it generates the IR frequency by itself (don't freak out: you don't need the FREQOUT) and
2) this module is active HIGH where BoeBot's sensor is active low
So your code should look more like:
Left_sensor = IN4
main: IF (Left_sensor = 1) THEN GOSUB turn ' was 0
ELSE
GOSUB forward
ENDIF
GOTO main
Comments
The BoeBot text shows pretty clearly how to make a more reliable object detector using an IR LED and a 38 kHz IR rcvr module. Scribbler gets left & right detection using one center mounted detector and 2 LEDs, one left one right.
-Phil
Seriously, thanks for your input. I have seen a few Fairchild metal-can phototransistors that do have an unused base lead. It's just there for moral support!
You're right: there are some with base connections. Frankly, I'm not sure what they're for, though. Biasing, perhaps?
-Phil
http://cgi.ebay.com.my/PnP-Opto-IR-Sensor-Basic-Stamp-PIC-AVR-MCU-Robot-/350233715179?pt=LH_DefaultDomain_0&hash=item518b8e61eb
it only consists of 1 output, the boe-bot sensor is similar to this sensor, but, i just dint work it out, can some one teach me ?
main:
FREQOUT 4, 1, 38500
Left_sensor = IN4
IF (Left_sensor = 0) THEN
GOSUB turn
ELSE
GOSUB forward
ENDIF
GOTO main
i wonder my robot dint get into ' turn ' command, and the sensor red LED just keep blinking when ther's an object in front of my robot, the LED should be a permanent light up when ther's an object, is'nt it ?
1) it generates the IR frequency by itself (don't freak out: you don't need the FREQOUT) and
2) this module is active HIGH where BoeBot's sensor is active low
So your code should look more like:
Left_sensor = IN4
main: IF (Left_sensor = 1) THEN GOSUB turn ' was 0
ELSE
GOSUB forward
ENDIF
GOTO main