Shop OBEX P1 Docs P2 Docs Learn Events
select problem — Parallax Forums

select problem

hijkerhijker Posts: 10
edited 2005-07-28 01:44 in Learn with BlocklyProp
hello, who can tell me what's wrong with the select statement.
I can't get it to work.


' {$STAMP BS2}
commando var byte
commando = 2

select commando
case 1
TOGGLE 15
case 2
TOGGLE 14
case 3
TOGGLE 13
case 4
TOGGLE 12
case else
HIGH 15:HIGH 14:HIGH 13:HIGH 12
endselect

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-07-24 07:09
    hijker -

    SELECT/CASE is a farily new addition to the PBASIC command set. You must instruct the Stamp Editor to use the latest rules and conventions, if you use newer commands. Place the following after the $STAMP directrive in your program:
    ' {$PBASIC 2.5}

    per the information found in the online PBASIC Help file.

    Regards,

    Bruce Bates
  • KenMKenM Posts: 657
    edited 2005-07-24 07:16
    FYI, you can replace HIGH 15:HIGH 14:HIGH 13:HIGH 12 with

    HIGH OUTD

    where OUTD represents pins 15, 14, 13, 12 as·a group.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken

    Post Edited (KenM) : 7/24/2005 2:22:32 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-24 16:45
    Ken,·

    ·· Something to be aware of when using OUT commands.· First of all, unlike TOGGLE and HIGH, the OUT commands (Such as OUTD) do not make the pins outputs.· In his code if the commando variable doesn't equal any of the first case statements, none of the pins would be HIGH then.· With the value he has preset only that one selected pin would be an output.

    ·· The idea is sound, all you would have to do is make sure that the direction registers·are set first to ensure these pins were outputs (DIRD = %1111).

    NOTE:· I see your post has been edited, making part of mine no longer make sense...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 7/28/2005 3:05:29 AM GMT
  • hijkerhijker Posts: 10
    edited 2005-07-24 19:08
    Thanks, with the

    ' {$PBASIC 2.5}
    every thing works fine.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-27 14:28
    Sorry, Ken, your command:

    · HIGH OUTD

    is bogus -- that is, it will not do what you want (make pins P12..P15 all high).· Remember that HIGH will accept a variable as its pin parameter, and OUTD is a nib variable.· So the command above will read the value of OUTD and set that single pin HIGH.

    If the pins are already outputs, you can do this:

    · OUTD = %1111

    If the pins haven't been defined as outputs, you'll need two lines:

    · DIRD = %1111
    · OUTD = %1111
    KenM said...
    FYI, you can replace HIGH 15:HIGH 14:HIGH 13:HIGH 12 with

    HIGH OUTD

    where OUTD represents pins 15, 14, 13, 12 as·a group.
    ·
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • KenMKenM Posts: 657
    edited 2005-07-28 01:44
    Thanks for the info.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken
Sign In or Register to comment.