Sensor Not Working When Unplugged
robomaniac
Posts: 4
I'm using the BASICStamp homework board for a school project and I'm having a weird issue. When I run my program which reads a touch sensor made from a radioshack microswitch while the board is plugged in through the serial cable the touch sensor triggers fine, however, when I unplug the board and try to run the same program the touch sensor fails to trigger. Any other part of the program works fine while unplugged. What's going on?
' {$STAMP BS2} ' {$PBASIC 2.5} touch_detect VAR Bit DO touch_detect = IN2 IF touch_detect = 1 THEN 'does not work fine unplugged HIGH 0 ELSE LOW 0 ENDIF PULSOUT 14, 150 'works fine unplugged PULSOUT 15, 750 LOOP
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
A typical resistor is 4.7K to 10K.
What this does is to provide a high logic (+5V) level at all times except when the switch contacts are closed at which point you get a low logic (0V) level. Probably without the resistor you're getting induced 60 cycle voltage in the wiring when the switch contacts are open and that's enough to trigger the I/O pin (which is high impedance and sensitive to induced voltages).
Genuses we're not ... We've just come across this problem before and either figured it out (typically with an oscilloscope) or had someone else tell us what to do.
Post Edited (Mike Green) : 5/3/2007 4:38:50 AM GMT