BS1USB Help
jkdalex
Posts: 8
Hi, I am new to basic stamp and I just bought the BS1USB (which uses basic stamp 1). I want to write a program that waits for a sequence of numbers on the usb and then does a corresponding action. The actions are not important. I expect to receive digits between 0-255. Can someone write a few sample lines of code to show me how to convert the below BS2 code to be used for BS1USB? Also, I cannot find the programming port number for the BS1USB. Would it be 8? Any help is appreciated!
' {$STAMP BS2}
' {$PBASIC 2.5}
Rpin CON 16 ' From programming port
BMode CON 84 ' BAUD mode -- Use 240 for BS2SX, BS2P
MaxTime CON 5000 ' Timeout Value – 3 seconds
Choice VAR Word ' Hold incoming data
LOW 0
Choice = 9
Main:
DEBUG CLS,"Would you like to turn the LED ON or OFF ? ",CR ' Request Choice
SERIN RPin, BMode, MaxTime, Timeout, [noparse][[/noparse]DEC Choice] ' Await serial data
IF Choice = 1 THEN
HIGH 0
DEBUG "LED turned ON",CR ' Notify user
GOTO Main
ELSEIF Choice = 2 THEN
LOW 0
DEBUG "LED turned OFF",CR ' Notify user
GOTO Main
ENDIF
GOTO Main
' {$STAMP BS2}
' {$PBASIC 2.5}
Rpin CON 16 ' From programming port
BMode CON 84 ' BAUD mode -- Use 240 for BS2SX, BS2P
MaxTime CON 5000 ' Timeout Value – 3 seconds
Choice VAR Word ' Hold incoming data
LOW 0
Choice = 9
Main:
DEBUG CLS,"Would you like to turn the LED ON or OFF ? ",CR ' Request Choice
SERIN RPin, BMode, MaxTime, Timeout, [noparse][[/noparse]DEC Choice] ' Await serial data
IF Choice = 1 THEN
HIGH 0
DEBUG "LED turned ON",CR ' Notify user
GOTO Main
ELSEIF Choice = 2 THEN
LOW 0
DEBUG "LED turned OFF",CR ' Notify user
GOTO Main
ENDIF
GOTO Main
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com