Shop OBEX P1 Docs P2 Docs Learn Events
Troubleshooting Basic Stamp Board I code to Homework Board — Parallax Forums

Troubleshooting Basic Stamp Board I code to Homework Board

abstractjabstractj Posts: 3
edited 2007-06-06 17:41 in BASIC Stamp
I tried to run the below code in my homework board and got the following error:

lable is missing ';'

SYMBOL in SYMBOL Servo_pin = 0 is highlighted

‘ {$STAMP BS1}
‘ {$PBASIC 1.0}

SYMBOL Servo_pin = 0

SYMBOL Temp = W0
SYMBOL Temp2 = W1
SYMBOL Rand = W2

SYMBOL RSensor = PIN1
SYMBOL LSensor = PIN2

Init:
Rand = 55

Main:
RANDOM Rand
Rand = Rand // 8
Rand = Rand + 8
PAUSE 2300
Temp = RSensor
Temp2 = LSensor
DEBUG Temp, Temp2, ” “
IF Temp = Temp2 THEN Center
IF Temp > Temp2 THEN Right
GOTO Left

Right:
DEBUG “Right”
FOR temp = 0 TO Rand
PULSOUT Servo_pin,120
PAUSE 30
NEXT
GOTO Main

Left:
DEBUG “Left”
FOR temp = 0 TO Rand
PULSOUT Servo_pin,190
PAUSE 30
NEXT
GOTO Main

Center:
‘FOR temp = 0 TO 2
‘PULSOUT Servo_pin,150
‘PAUSE 20
‘NEXT
GOTO Main




I've tried running in Stamp 2.0 and still did not work.

The above code was taken from RoboSheep project:
http://www.2robots.com/2006/10/21/robosheep/

Thanks for helping.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-06-06 04:28
    Where did it give the error? what line? Also this is BS1 code and the homework board, I believe is only bs2

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-06 14:04
    Franklin is correct…BS1 code won’t run on a BS2. The BS1 uses only the PBASIC 1.0 syntax whereas the BS2 and higher use PBASIC 2.0 or 2.5 syntax. The architectures are also different. You will need to convert the code for use on the BS2. A complete list of commands and list of stamp models that support these commands is listed in the Editor Help File by clicking on Help/Contents and then clicking on the words PBASIC Reference (not the plus). Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • abstractjabstractj Posts: 3
    edited 2007-06-06 16:22
    Hi Chris,

    I didn't see the SYMBOL syntax in the PBASIC sytax guide. I wish there is some type of tool that can convert SB I to SB II code standard...

    Franklin,

    The error happens in line 4.

    SYMBOL·Servo_pin·=·0

    Thanks,

    Joel
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-06 16:29
    Joel,

    That is listed un Memory and Variables under Defining Variables. This is different for the BS2, which uses the format:

    Servo_pin VAR Byte

    Or

    Servo_pin CON 0 (If you’re defining a constant)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • abstractjabstractj Posts: 3
    edited 2007-06-06 17:13
    Thanks for the clarification Chris. It really helps. I just picked up my board and coding Basic for the first time. Taking awhile to understand all of the syntax.

    Basic Stamp 1 Code:
    '{$STAMP BS1}
    '{$PBASIC 1.0}
    
    SYMBOL Temp = W0
    SYMBOL Temp2 = W1
    SYMBOL Rand = W2
    
    SYMBOL RSensor = PIN1
    SYMBOL LSensor = PIN2
    
    



    Would look like this in BSBII:
    '{$STAMP BS2}
    '{$PBASIC 2.0}
    Temp    VAR    Word
    Temp2   VAR    Word
    Rand      VAR    Word
    
    RSensor   VAR    IN1 
    LSensor    VAR   IN2
    
    



    Am I getting wamer with this?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-06 17:41
    Joel,

    Everything looks good. If you were using PBASIC 2.5 you could set up the I/O declarations as follows:

    RSensor PIN 1
    LSensor PIN 2

    Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.