Shop OBEX P1 Docs P2 Docs Learn Events
BS1USB Help — Parallax Forums

BS1USB Help

jkdalexjkdalex Posts: 8
edited 2006-07-15 01:18 in BASIC Stamp
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

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-14 19:56
    You can't access the programming port directly with the BS1, but you can use the DEBUG statement to transfer information to an attached PC. There is an article in Nuts and Volts on decoding the DEBUG information <http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv20.pdf>. Unfortunately, you can't use the built-in USB to send info to the Stamp.
  • jkdalexjkdalex Posts: 8
    edited 2006-07-14 21:25
    Hi mike, thanks for your reply. So does that mean there is no way to wait for an input command from the PC with basic stamp 1?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-15 00:54
    Not without tying it to the serial port through a line driver.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-15 01:18
    You end up needing to use a pin on the BS1 to sense the signal. The big problem is that the BS1USB uses a built-in USB to serial converter and it's all surface mount and very tiny. Otherwise, you could connect the program receive line to one of the regular BS1 pins and then use SERIN.
Sign In or Register to comment.