Shop OBEX P1 Docs P2 Docs Learn Events
Trouble with LED's — Parallax Forums

Trouble with LED's

BLUBLU Posts: 2
edited 2011-05-12 08:10 in Robotics
Having some trouble getting an LED to simple light up on a simple circuit that tests the QTI sensors.. everything is wired right and the code is word for word from the book so I do not know what is going on I have even tried to swap out parts. Can someone shed some light on the situation? Heres the code...
' {$STAMP BS2}
' {$PBASIC 2.5}
'(I/O Def)
Lmotor PIN 13
Rmotor PIN 12
LLP PIN 10
LLI PIN 9
RLP PIN 7
RLI PIN 8
StartLED PIN 1
'(constants)
LFF CON 1000
LFS CON 800
LS CON 750
LRS CON 700
LRF CON 500
RFF CON 500
RFS CON 700
RS CON 750
RRS CON 800
RRF CON 1000
'(variables)
lLine VAR Word
rLine VAR Word
lineBits VAR Nib
lbLeft VAR lineBits.BIT1
lbRight VAR lineBits.BIT0
pulses VAR Byte
temp VAR Byte
'(EEPROM Data)
RunStatus DATA $00
'(initialization)
Reset:
READ RunStatus, temp
temp= ~temp
WRITE RunStatus, temp
IF (temp > 0) THEN END
Start_Delay:
HIGH StartLED
PAUSE 5000
LOW StartLED
'(code)
Main:
GOSUB Read_Line_Sensors
'sumo movement
BRANCH lineBits, [Go_Fwd, Spin_Left, Spin_Right, About_Face]
Go_Fwd:
PULSOUT Lmotor, LFF
PULSOUT Rmotor, RFF
GOTO Main
Spin_Left:
FOR pulses = 1 TO 20
PULSOUT Lmotor, LRF
PULSOUT Rmotor, RFF
PAUSE 20
NEXT
GOTO Main
Spin_Right:
FOR pulses = 1 TO 20
PULSOUT Lmotor, LFF
PULSOUT Rmotor, RRF
PAUSE 20
NEXT
GOTO Main
About_Face:
FOR pulses = 1 TO 10
PULSOUT Lmotor, LRF
PULSOUT Rmotor, RRF
PAUSE 20
NEXT
FOR pulses = 1 TO 30
PULSOUT Lmotor, LFF
PULSOUT Rmotor, RRF
PAUSE 20
NEXT
GOTO Main
END
'(Subroutines)
Read_Line_Sensors:
HIGH LLP
HIGH RLP
HIGH LLI
HIGH RLI
PAUSE 1
RCTIME LLI, 1, lLine
RCTIME RLI, 1, rLine
LOW LLP
LOW RLP
LOOKDOWN lLine, >=[1000, 0], lbLeft
LOOKDOWN rLine, >=[1000, 0], lbRight
RETURN

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-05-12 07:55
    attachment.php?attachmentid=78421&d=1297987572
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-05-12 08:10
    Number one problem with your code is -

    not a single DEBUG command !

    See attched snippet and figure it out.
    If you cannot see it , ask for help again.






    temp VAR Byte
    '(EEPROM Data)
    RunStatus DATA $00
    DEBUG "'(initialization)",CR

    Reset:
    READ RunStatus, temp
    temp= ~temp
    DEBUG ? temp
    'STOP

    WRITE RunStatus, temp
    DEBUG ? temp

    IF (temp > 0) THEN END
    Start_Delay:
    HIGH StartLED
    PAUSE 5000
    LOW StartLED
Sign In or Register to comment.