Shop OBEX P1 Docs P2 Docs Learn Events
Question on behaf of a friend.. — Parallax Forums

Question on behaf of a friend..

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2014-09-25 23:28 in BASIC Stamp
I'm not a BASIC STAMP guy, but I've been asked the following question..

Hi Jeff,
I'm trying to make a program for my B Stamp that when you push a button
it turns a light on but what I got,
LEDs       VAR     OUTA
LEDsD     VAR     DIRA
DTm        CON     100
Led:
  LEDsD = %1111
Run:
  INPUT 15
  IF (IN15=*) THEN LEDs = %1111
  PAUSE DTm
  LEDs = %0000
GOTO Run,

the button don't seem to do nothing. The lights just flutter.

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-09-22 18:18
    With an LED on P0 and a pushbutton, properly configured, on P15
    with
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    INPUT 15
    OUTPUT 0
    
    Main:
     IF (IN15=0) THEN
      OUT0 = 0
     ELSE
      OUT1 = 1
     ENDIF
     GOTO Main
    

    the LED will be On as long as the button is held down.

    PE - This, assuming the pushbutton connects the Input to +5
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-09-23 09:10
    Agreed. You would have to know how everything was wired in order to be sure of the code.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-09-25 12:24
    So, no follow-up then?
  • MoskogMoskog Posts: 554
    edited 2014-09-25 12:47
    PJ Allen wrote: »
    So, no follow-up then?

    OK, the OUT1 is confusing!
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-09-25 17:15
    Moskog wrote: »
    OK, the OUT1 is confusing!

    Confusing? It's not confusing - it's wrong! :zombie:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    INPUT 15
    OUTPUT 0
    
    Main:
     IF (IN15=0) THEN
      OUT0 = 0
     ELSE
      [COLOR="#FF0000"]OUT0 = 1[/COLOR]
     ENDIF
     GOTO Main
    

    Wire the switch in acc. with the "Active-High" example given for BUTTON (in PBASIC Help) and place the LED circuit between P0 and Vss.

    Fair enough?
  • WhitWhit Posts: 4,191
    edited 2014-09-25 19:04
    PJ Allen wrote: »
    Confusing? It's not confusing - it's wrong! :zombie:

    @P.J. - LOL! You're the best!
  • ercoerco Posts: 20,257
    edited 2014-09-25 23:28
    Me, I'm a LOW 0 HIGH 0 kinda guy.
Sign In or Register to comment.