Shop OBEX P1 Docs P2 Docs Learn Events
Help With Basics — Parallax Forums

Help With Basics

'O Flyer'O Flyer Posts: 9
edited 2005-10-27 19:35 in BASIC Stamp
Need some help with the basics:

I feel I'm quite familiar with the Stamp Manual, but maybe the following problem is just TOO basic to be covered in it. I have a slide switch and two pushbutton switches with which I'm switching 5 volts to i/o pins 6, 7 & 8 respectively·of my BS2e Stamp. I'll call the switches sldSwitch, redButton and blkButton respectively (the pushbuttons do have the suggested 10k ohm "pull-down" resistors soldered to them). The Editor (v2.2) simply won't let me declare each as a bit variable AND make a PIN declaration for each.·Initially at least I'd like a reply·without reference to the BUTTON commands, but my (unsuccessful) experiments with BUTTON commands seem to suggest that the pushbutton switch being "BUTTONed" also isn't being properly declared as a bit variable, and needs to be.·Could you offer some help?
· ·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 00:14
    The manual, of course, shows proper use of syntax and cannot cover every possible situation.· That said, we have lots of books and "What's A Microcontroller?" or "StampWorks" (if you're more experienced) would help you out.

    What you're missing is that I/O pins are treated as bit variables when you use the PIN declaration.· So you can do this:

    SlideSw···· PIN··· 0
    RedBtn····· PIN··· 1
    BlackBtn· · PIN·· ·2

    buttons···· VAR·· ·Nib

    Main:
    · DO : LOOP UNTIL (SlideSw = 1)······· ' wait for slide switch to close

    Scan_Buttons:
    · buttons.BIT0 = RedBtn··············· ' make copy of red button
    · buttons.BIT1 = BlackBtn············· ' make copy of black button

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • 'O Flyer'O Flyer Posts: 9
    edited 2005-10-27 19:24
    Hi Jon,

    Looks like Halloween is approaching!

    Thanks for your informative reply yesterday. Working on another question for you or your dept. Grateful for your help.

    Vern Roach/O'Flyer
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 19:35
    Remember... we have LOTS of printed documentation that will assist so that you don't have wait on me or another forum member:

    -- PBASIC Syntax & Reference Manual
    -- Online help file
    -- What's A Microcontroller? (educational book)

    Start with these sources, as they will answer 98% of your questions and teach you a lot along the way that will be important to know.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.