Shop OBEX P1 Docs P2 Docs Learn Events
Light on light of — Parallax Forums

Light on light of

RobeRobe Posts: 13
edited 2005-02-27 08:40 in BASIC Stamp
Hello every one
i am trying to turn a led on, off· wiht···a ·signal to the same i/o
one time for on one time for on· and so on.
Could you·please help, ·so·far i got· this

do
if in0 =1 then
high 5
pause 1000

else if in0 = 1 then
low 1
pause 1000

end if

loop
·

Comments

  • Robert SchwartzRobert Schwartz Posts: 141
    edited 2005-02-26 05:49
    Your IF statement doesn't really make sense. The ELSE IF will never be triggered since it has the same condition as the IF statement preceding it. I think that this is what you are trying to do:

    LedControl var 0
    LED var 1

    Start:
    DO
    IF LedControl = 1 THEN
    HIGH LED:
    PAUSE 1000:
    ELSE IF LedControl = 0 THEN
    LOW LED:
    PAUSE 1000:
    ENDIF
    LOOP
    END

    This will change the LED's status (on or off) depending on whether or not PIN 0 is high or low.
    Could you please explain your problem?
  • RobeRobe Posts: 13
    edited 2005-02-26 06:15
    Firts thank you for replying

    i am sending a high signal to the stamp to turn the led on

    then another high signal again to turn it off and another high signal

    to turn it on again, and so on i am trying to turn led off and on

    with the same high signal to the same i/o over and over again.
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-02-26 07:17
    The you need something more like this...


    LOW 1
    Start:
    DO
        IF IN0 = 1 THEN          'Check for P0 to go HIGH
            TOGGLE 1               'TOGGLE Output pin P1
            PAUSE 1000            'Pause for 1 second Debounce
            DO WHILE IN0=1     'Wait for P0 to go LOW (Release)
            LOOP 
            PAUSE 1000            'Pause for 1 second Debounce 
        ENDIF
    LOOP
    END
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071

    Post Edited (Beau Schwabe) : 2/26/2005 7:22:52 AM GMT
  • RobeRobe Posts: 13
    edited 2005-02-27 08:40
    Thank you so much
Sign In or Register to comment.