Download presentation
Presentation is loading. Please wait.
1
OEM BASIC Stamp 2sx 220 Ohm
2
Wiring diagram 2 OEM BASIC Stamp 2sx Microcontroller chip COM port
9 V battery 220 Ohm 220 Ohm LED Buzzer IR Receiver IR LED 5V SIG Note: GND OUT Vdd - is connection to negative pole of the battery PING
3
Example 08a “PING” File: “Example-08a.bsx” ' Example 08a
' {$STAMP BS2sx} ' {$PBASIC 2.5} ' connect SIG pin of PING to pin 15 of BS2sx time VAR Word DO PULSOUT 15, 13 PULSIN 15, 1, time DEBUG HOME, "time = ", DEC5 time time = time */ $0CD time = time / 2 time = time ** 2257 DEBUG CR, "Distance = ", DEC4 time, " cm" PAUSE 100 LOOP
4
Example 08b “PING” File: “Example-08b.bsx” ' Example 08b
' {$STAMP BS2sx} ' {$PBASIC 2.5} ' connect SIG pin of PING to pin 15 of BS2sx time VAR Word cm VAR Word freq VAR Word DO PULSOUT 15, 13 PULSIN 15, 1, time DEBUG HOME, "time = ", DEC5 time time = time */ $0CD time = time / 2 cm = time ** 2257 DEBUG CR, "Distance = ", DEC4 cm, " cm" freq = cm * 50 FREQOUT 1,100,freq PAUSE 50 LOOP
5
Example 09 “IR LED and receiver” File: “Example-09.bsx” ' Example 09
' {$STAMP BS2sx} ' {$PBASIC 2.5} IR_detect VAR Bit LOW 7 IR_detect = 0 DO IR: FREQOUT 7,1,38500 IR_detect = IN8 IF IR_detect = 0 THEN unbroken DEBUG HOME, "Beam is broken; object detected " HIGH 4 FREQOUT 1,50,1900 LOW 4 GOTO IR unbroken: DEBUG HOME, "Beam is unbroken; object not detected." LOOP END
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.