Shop OBEX P1 Docs P2 Docs Learn Events
Problems with the IR Obect Indicators — TestBothIrAndIndicators — Parallax Forums

Problems with the IR Obect Indicators — TestBothIrAndIndicators

eMarston15eMarston15 Posts: 3
edited 2014-04-04 08:33 in Accessories
Hey, everyone. I was hoping I could get some help with the script from chapter 7 activity #2, TestBothIrAndIndicators.bs2.

When I run the script (below) it highlights DO (under [ Main routine ] and comes up with an error saying "Expected a constant, variable, unary operator, or '('.

If someone could take a look at the script and let me know if there's something wrong with it, or if I should just take a look at the wiring again to see if I missed anything—which isn't likely, because I have checked about three times now, and taken everything off and put it back on one piece at a time—that would be greatly appreciated. Thanks!



' Robotics with the Boe-Bot - TestBothIrAndIndicators.bs2
' Test IR object detection circuits.

' {$STAMP BS2}
' {$PBASIC 2.5}

'
[ Variables ]

irDetectLeft VAR Bit
irDetectRight VAR Bit

'
[ Initialization ]

DEBUG "Testing piezpspeaker..."
FREQOUT 4, 2000, 3000

DEBUG CLS,
"IR DETECTORS", CR,
"Left Right", CR,
"

",

'
[ Main Routine ]

DO
FREQOUT 8, 1, 38500
irDetectLeft = IN9

FREQOUT 2, 1, 38500
irDetectRight

IF (irDetectLeft = 0) THEN
HIGH 10
ELSE
LOW 10
ENDIF

IF (irDetectRight = 0)THEN
HIGH 1
ELSE
LOW 1
ENDIF

DEBUG CRSRXY 2, 3, BIN1 irDetectLeft,
DEBUG CRSRXY 9, 3, BIN1 irDetetRight

PAUSE 100
LOOP


————————————————————

Any suggestions you guys have would be appreciated, if nothing comes up then I'll probably end up calling tech support. Thanks, guys!

Comments

  • davejamesdavejames Posts: 4,047
    edited 2014-04-04 08:16
    eMarston15 wrote: »
    ' Robotics with the Boe-Bot - TestBothIrAndIndicators.bs2
    ' Test IR object detection circuits.
    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    ' -----[ Variables ]-----
    
    irDetectLeft    VAR    Bit
    irDetectRight   VAR    Bit
    
    ' -----[ Initialization ]-----
    
    DEBUG "Testing piezpspeaker..."
    FREQOUT 4, 2000, 3000
    
    DEBUG CLS,
          "IR DETECTORS", CR,
          "Left   Right", CR,
          "-----  -----",
    
    ' -----[ Main Routine ]-----
    
    DO
      FREQOUT 8, 1, 38500
      irDetectLeft = IN9
    
      FREQOUT 2, 1, 38500
      irDetectRight '<-------------------***something is missing here, there's no assignment
    
      IF (irDetectLeft = 0) THEN
        HIGH 10
      ELSE
        LOW 10
      ENDIF
    
      IF (irDetectRight = 0)THEN
        HIGH 1
      ELSE
        LOW 1
      ENDIF
    
      DEBUG CRSRXY 2, 3, BIN1 irDetectLeft,
      DEBUG CRSRXY 9, 3, BIN1 irDetetRight
    
      PAUSE 100
    LOOP
    

    Hello eMarston15 - welcome to the Forum.

    It would appear that irDetectRight is "orphaned", with no value assignment.
  • PublisonPublison Posts: 12,366
    edited 2014-04-04 08:33
    Line 20--extra comma
    Line 29--missing = IN0
    Line 43-- missing comma after CRSRXY
    Line 44--DEBUG statement does not belong because of the comma on the preceding line.
    Line 44--irDetectRight spelled wrong.
Sign In or Register to comment.