Shop OBEX P1 Docs P2 Docs Learn Events
Simple Newbie Question — Parallax Forums

Simple Newbie Question

ArchiverArchiver Posts: 46,084
edited 2000-09-15 12:48 in General Discussion
Simple Newbie Question

Hello all,
······· I have a REALLY dumb question, but I have never had to do this in any of my dealings with programming a Basic Stamp. How, with a Stamp II, do I check to see if a PIN is set to HIGH or LOW. In other words...by default, the PIN should be set to LOW by the stamp...however, the device connected to the PIN may set it to HIGH...how can I tell if this has happened? Any help is GREATLY appreciated.

---
Thomas Cameron
tom@patcameron.ne.mediaone.net

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-09-15 12:48
    Hi Tom,

    Well, by default all pins are inputs. You can set them to outputs using
    OUTPUT 1 (for pin 1) and also some commands do this automatically (HIGH 1,
    LOW 1, etc.).

    You can switch back to input mode with INPUT 1 (again for pin 1).

    Now, if the pin is an output, you don't really want to read its state. Why?
    Because if an external device has set it to something else, your Stamp and
    the device are "fighting". At best you get an unknown state. At worst, you
    blow up one or both of the devices.

    However, if the pin is an input, try this:

    top:
    if in1=0 then pin1is0
    high 2
    goto top
    pin1is0:
    low 2
    goto top

    This should make pin2 reflect the state of pin1. You can also read the
    inputs in grouups using things like INA (first 4 bits), IND (last 4 bits),
    INL (first 8 bits), INH (last 8 bits), etc.

    Hope that helps. You might be interested in the Basic Stamp FAQ at
    http://www.al-williams.com/wd5gnr/stampfaq.htm.

    Regards,

    Al Williams
    AWC

    P.S. You might also enjoy my book "Microcontroller Projects with Basic
    Stamps" -- see http://www.al-williams.com/awce/sbook.htm



    Original Message
    From: Tom Cameron [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=VDqfTm99iAmmh_yfqzuRt6-u9fc68GcYdlKy8xZVxWhfzFIWjNJSr-xXvJGxHf4vq2dJo5_EhqTnVS6gaHcbBCGPVJw]tom@p...[/url
    Sent: Friday, September 15, 2000 2:15 AM
    To: 'basicstamps@egroups.com'
    Subject: [noparse][[/noparse]basicstamps] Simple Newbie Question


    Hello all,
    I have a REALLY dumb question, but I have never had to do this in
    any of my dealings with programming a Basic Stamp. How, with a Stamp II, do
    I check to see if a PIN is set to HIGH or LOW. In other words...by default,
    the PIN should be set to LOW by the stamp...however, the device connected to
    the PIN may set it to HIGH...how can I tell if this has happened? Any help
    is GREATLY appreciated.
    ---
    Thomas Cameron
    tom@p...
Sign In or Register to comment.