Shop OBEX P1 Docs P2 Docs Learn Events
Problem with pinX command w/ II & 2SX — Parallax Forums

Problem with pinX command w/ II & 2SX

ArchiverArchiver Posts: 46,084
edited 2000-07-21 18:08 in General Discussion
I am new to this list, so please excuse any redundancy in this question. I
tried emailing Parallax's STAMP support but the email will not go through... (?)

I am trying out a very simple program that will light a LED when a toggle
switch is in a given position. The program is as follows:

again:
if pin0=1 then beginning
if pin0=1 then ending

beginning:
high 7
pause 250
goto again

ending:
low 7
pause 1000
goto again

The problem is that whenever I try to download the program to the 2SX chip or II
chip (using the correct software) I get a "pin0 is undefined" error. I have
tried using caps, spaces, etc. to see whether it was a syntax problem and have
not gotten anywhere. This program is almost straight out of a learning book I
am working with and nowhere does it say whether I have to define "pin0" or why I
might be getting an error. The wiring is as follows:

p0 => Vdd -> 1k resistor -> toggle switch -> p0
p7 => Vdd -> 1k resistor -> LED -> p7

I can get the program to work without the if...then statement involving checking
the state of p0. Hmmm... What am I doing wrong??? Any help would be much
appreciated.

Regards,
SNF

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-07-21 18:01
    I'm sure you will get a few answers for this, but here's mine:

    pinX is for the Stamp I. For the II and IISX you need to use inX and outX.

    again:
    if in1=1 then beginning

    Or even:
    if in1 then beginning


    However, I'm not clear on your two if statements
    > if pin0=1 then beginning
    > if pin0=1 then ending
    They test the same thing which means the second one will very likely never
    execute unless it sees an edge between the two statements.

    I'm thinking:

    top:
    if in0 then offled
    high 7
    goto top
    offled:
    low 7
    goto top

    or even:
    OUTPUT 7
    again:
    out7=in0
    goto again


    Something like that? Notice that HIGH and LOW implicitly call OUTPUT but if
    you are using outX, you have to use an OUTPUT statement.

    Good luck!

    Al Williams
    AWC
    *Basic Stamp FAQ: http://www.al-williams.com/wd5gnr/stampfaq.htm



    >
    Original Message
    > From: SNFettig Listserv [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=AkoMrE9eZfTLHxW-aMvNgp0cyc4GAWp6PYZsjFWybKTwbN3zv7GJY2oG1gjGM0hXpKuImM5rtgBDWiyReX4o]lists@s...[/url
    > Sent: Friday, July 21, 2000 11:25 AM
    > To: basicstamps@egroups.com
    > Subject: [noparse][[/noparse]basicstamps] Problem with pinX command w/ II & 2SX
    >
    >
    > I am new to this list, so please excuse any redundancy in
    > this question. I tried emailing Parallax's STAMP support but the
    > email will not go through... (?)
    > I am trying out a very simple program that will light a LED
    > when a toggle switch is in a given position. The program is as follows:
    >
    > again:
    > if pin0=1 then beginning
    > if pin0=1 then ending
    >
    > beginning:
    > high 7
    > pause 250
    > goto again
    >
    > ending:
    > low 7
    > pause 1000
    > goto again
    >
    > The problem is that whenever I try to download the program to the
    > 2SX chip or II chip (using the correct software) I get a "pin0 is
    > undefined" error. I have tried using caps, spaces, etc. to see
    > whether it was a syntax problem and have not gotten anywhere.
    > This program is almost straight out of a learning book I am
    > working with and nowhere does it say whether I have to define
    > "pin0" or why I might be getting an error. The wiring is as follows:
    >
    > p0 => Vdd -> 1k resistor -> toggle switch -> p0
    > p7 => Vdd -> 1k resistor -> LED -> p7
    >
    > I can get the program to work without the if...then statement
    > involving checking the state of p0. Hmmm... What am I doing
    > wrong??? Any help would be much appreciated.
    >
    > Regards,
    > SNF
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-07-21 18:08
    Change pin0 to IN0. This will take care of the undefined symbol for the BSII.

    Your first statement "if IN0=1 then beginning" will not let program execution
    fall-through to
    the second statement "if IN0=1 then ending", (unless IN0 = 0).

    Why..? If IN0 = 1 program execution is sent to beginning. If IN0=0 you will
    fall-through
    to beginning because you didn't test to see if IN0=0 and jump to ending.

    again:
    if IN0=1 then beginning <--- if IN0 = 1 you will never get to the second
    line.
    if IN0=1 then ending <--- if IN0 = 0 would take you to ending:

    beginning:
    high 7
    pause 250
    goto again

    ending:
    low 7
    pause 1000
    goto again

    The IF IN0 THEN is a logical operation that will test the logic state of the
    input
    pin. Test
    the input pin for each logic value ie,, 0 or 1 to make a decision based on the
    state
    of the
    input.

    Example:

    again:
    if IN0=1 then beginning
    if IN0=0 then ending

    beginning:
    high 7
    pause 250
    goto again

    ending:
    low 7
    pause 1000
    goto again


    This should get you there......[noparse]:o[/noparse]]

    Regards,

    Bruce
    http://www.rentron.com


    Original Message
    From: "SNFettig Listserv" <lists@s...>
    To: <basicstamps@egroups.com>
    Sent: Friday, July 21, 2000 10:25 AM
    Subject: [noparse][[/noparse]basicstamps] Problem with pinX command w/ II & 2SX


    | I am new to this list, so please excuse any redundancy in this question.
    I
    tried emailing Parallax's STAMP support but the email will not go through... (?)
    | I am trying out a very simple program that will light a LED when a toggle
    switch is in a given position. The program is as follows:
    |
    | again:
    | if pin0=1 then beginning
    | if pin0=1 then ending
    |
    | beginning:
    | high 7
    | pause 250
    | goto again
    |
    | ending:
    | low 7
    | pause 1000
    | goto again
    |
    | The problem is that whenever I try to download the program to the 2SX chip or
    II
    chip (using the correct software) I get a "pin0 is undefined" error. I have
    tried
    using caps, spaces, etc. to see whether it was a syntax problem and have not
    gotten
    anywhere. This program is almost straight out of a learning book I am working
    with
    and nowhere does it say whether I have to define "pin0" or why I might be
    getting an
    error. The wiring is as follows:
    |
    | p0 => Vdd -> 1k resistor -> toggle switch -> p0
    | p7 => Vdd -> 1k resistor -> LED -> p7
    |
    | I can get the program to work without the if...then statement involving
    checking
    the state of p0. Hmmm... What am I doing wrong??? Any help would be much
    appreciated.
    |
    | Regards,
    | SNF
    |
    |
    |
    |
    |
Sign In or Register to comment.