Shop OBEX P1 Docs P2 Docs Learn Events
command choice help — Parallax Forums

command choice help

computoncomputon Posts: 6
edited 2005-01-30 18:39 in BASIC Stamp
I am writing a Basic Stamp program where I need to know the value
on a pin. In some cases, I use rctime, when I have a range of possible
values. However, what do I use for the simpler case, when I just need
a "yes" or "no"--if the circuit is complete, I want a 1 ("yes"), and if it's
incomplete, I want a 0 ("no"). Can I use rctime for this, too? I do not
want to use resistors and capacitors for these circuits.

Thanks.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-30 18:39
    Your case is the easiest of pin status -- high or low.· Connect this circuit:

    attachment.php?attachmentid=36994


    Then run this little demo:

    ' {$STAMP BS2} 
    ' {$PBASIC 2.5} 
    
    Status    PIN    0 
    
    IsOn      CON    1 
    IsOff     CON    0 
    
    Main: 
      IF (Status = IsOn) THEN 
        DEBUG HOME, "System Status: On " 
      ELSE 
        DEBUG HOME, "System Status: Off" 
      ENDIF 
      GOTO Main
    


    Note how using PIN and CON definitions make the program very easy to understand and maintain.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
    240 x 201 - 2K
Sign In or Register to comment.