Shop OBEX P1 Docs P2 Docs Learn Events
Newbie question: LED's won't go off ... — Parallax Forums

Newbie question: LED's won't go off ...

ZebZiggleZebZiggle Posts: 3
edited 2009-04-19 13:13 in BASIC Stamp
Hi, I'm using a BS2-SX with an older Activity Board (the one with all the buttons, speaker, etc.)

I whipped up a really simple program to flash the LED's

' {$STAMP BS2sx}
' {$PBASIC 2.5}

counter VAR Byte
light VAR Byte

FOR light = 8 TO 11
  FOR counter = 1 TO 5
    DEBUG DEC light, DEC counter, ",", CR
    HIGH light
    PAUSE 500
    LOW light
    PAUSE 500
  NEXT
NEXT
DEBUG "Done"
LOW 8
LOW 9
LOW 10
LOW 11
END





But the LED's all stay on at the end ... however they do flash during the inner loop?! Odd. Even the forced "Low's" at the end fail to make the LED's go off.

Also, the board seems to blink about every 2 seconds after the END. P11 is hooked up to the speaker, so you hear a little "tick" about every 2 secs and all the LED's flicker.

Any idea what's going on here? Is it something with my code or a quirk of the activity board?

confused.gif

Comments

  • JimmioJimmio Posts: 43
    edited 2009-04-17 12:37
    I do believe it's a case of DBS. Dead Battery Syndrome. Change the batteries and try again or ask your operator for assistance. =P

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Info on all kinds of robosports:
    www.freewebs.com/robotbattles
  • BeanBean Posts: 8,129
    edited 2009-04-17 12:39
    Sounds like you have the LEDs connected as active low. You probably have the cathode going to the stamp pin, and the anode going to Vdd. Turn the LED around and connect the cathode to Vss and it should work right.

    As for the blink every 2 seconds, I think the END statement actually puts the stamp to sleep where it wake up every 1.8 seconds causing the "blips". Use STOP instead of END to prevent this.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • ZebZiggleZebZiggle Posts: 3
    edited 2009-04-17 17:52
    Thanks for the prompt reply guys.

    Jimmio, it's using a brick power supply, so it's not a battery issue.

    Bean, the LED's were pre-assembled on the Activity board (like I said, it's an old board), so the led's can easily be flipped. Not only that, they *do* blink during the inner loop. They just end up always in the ON state, even with the explicit LOW.

    I'll try the STOP command and see what that does ... makes sense though. Thx!

    Cheers,
    -Z
  • FranklinFranklin Posts: 4,747
    edited 2009-04-18 01:40
    Try setting them all high at the end.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-04-19 02:06
    The 2 seconds pulse after the end of program sounds familiar. I think it has to do something with PIC interpreter initialization.

    To be sure - ask Parallax guys.
  • FranklinFranklin Posts: 4,747
    edited 2009-04-19 05:38
    If you END a program the chip wakes up every two seconds or so to see if you want to do something else. Try a STOP.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ZebZiggleZebZiggle Posts: 3
    edited 2009-04-19 13:13
    Thanks y'all.

    Seems the activity board is active high on all pins on reset.

    I changed my code accordingly and everything works fine now.

    The 2.3 sec flicker is a documented feature under the END/STOP section. I just didn't know there were two commands to achieve essentially the same result.

    Now ... onto trickier problems!

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}
    
    counter VAR Byte
    light VAR Byte
    
    FOR light = 8 TO 11
        HIGH light
    NEXT
    
    FOR light = 8 TO 11
      FOR counter = 1 TO 5
        DEBUG DEC light, DEC counter, ",", CR
        LOW light
        PAUSE 500
        HIGH light
        PAUSE 500
      NEXT
    NEXT
    DEBUG "Done"
    END
    
    
Sign In or Register to comment.