PDA

View Full Version : Multiple pins



StarMan
05-01-2007, 04:18 AM
Is there a way (like a HIGH or LOW command) to output two or more pins at once? I tried to search the subject but found nothing.

Thanks,

Chris I.

Mike Green
05-01-2007, 04:26 AM
You can directly access groups of 4 or 8 pins using names like OUTL/OUTH and the nibble equivalents. Look at the section of the PBasic manual that talks about memory for the BS2. It lists all of these special names (and suffixes) and gives examples of their use.

StarMan
05-01-2007, 09:38 AM
Thanks Mike. I read the similar section in the Pbasic editor help file but the manual is clearer. I get it now.

StarMan
05-03-2007, 06:02 AM
Hmmm, Well, I thought I understood but I guess not. My understanding is that if I use OUTD = 1, pins 12 thru 15 will output high. But only pin 12 goes high.

I tried this little piece of test code with LEDs on pins 12 thru 15. The HIGH commands work, OUTD does not. Only pin 12 goes high with OUTD.

' -----[ Initialization ]--------------------------------------------------
DIRS = %1111000000000000



' -----[ Program Code ]----------------------------------------------------

Main:
HIGH 12
PAUSE 1000
LOW 12
PAUSE 1000
HIGH 13
PAUSE 1000
LOW 13
PAUSE 1000
HIGH 14
PAUSE 1000
LOW 14
PAUSE 1000
HIGH 15
PAUSE 1000
LOW 15
PAUSE 1000

OUTD = 1
PAUSE 1000
OUTD = 0
PAUSE 1000

GOTO Main

It has to be something simple. Any Guidance?

Thanks,

Chris I.

Mike Green
05-03-2007, 06:19 AM
When you write "OUTD = 1", you're really writing "OUTD = %0001" which sets the pins the way you're seeing. If you want to set all of them high, you have to write "OUTD = %1111" or "OUTD = $F" or "OUTD = 15"

StarMan
05-03-2007, 06:36 AM
Ha! More simple than I thought.

Thanks Mike.