Help With Basics
'O Flyer
Posts: 9
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?
· ·
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
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
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
-- 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