set multiple pins high on one line. And other quicies
mikeslaney
Posts: 17
Hi there,
Newbie.
How do I set multiple pins HIGH on one line? That is to say:
Can I do something like:
HIGH pin 0, 1, 2, 3, ...
I think I tried all the iterations but have still come up with nothing. The examples I have found only list/state one pin.
How do I increment or decrement pin#'s in a FOR loop? II can't I set multiple pins High or Low on one line, I could use·FOR loop.
Could you please recommend a very good book that is full of examples?
Thanks,
Mike Slaney
·
Newbie.
How do I set multiple pins HIGH on one line? That is to say:
Can I do something like:
HIGH pin 0, 1, 2, 3, ...
I think I tried all the iterations but have still come up with nothing. The examples I have found only list/state one pin.
How do I increment or decrement pin#'s in a FOR loop? II can't I set multiple pins High or Low on one line, I could use·FOR loop.
Could you please recommend a very good book that is full of examples?
Thanks,
Mike Slaney
·
Comments
DIRS = %0000000000001111 ' make pins 0 - 3 outputs
OUTS = %0000000000001111 ' make pins 0 - 3 high
Section 4 of the manual explains DIRS, OUTS, and INS and how the can be used in smaller chunks as well.
Check our website -- we have done of good books.· Start with "What's A Microcontroller?"· We also have about 110 Nuts & Volts "Stamp Applications" articles that can be downloaded.· Have at it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
However, only pins 0-8 are going high when I use the DIRS and OUTS with %11111111111111.
I'm still doing some studying on it but you might have a quick answer.
Thanks,
Mike
It might be easier to group them; DIRL and OUTL handle pins 0 - 7; DIRH and OUTH handle pins 8 - 15.
For finer control you can use DIRA (pins 0 - 3), DIRB (pins 4 - 7), DIRC (pins 8 - 11), and DIRD (12 - 15) -- and there are corresponding OUTx aliases. The manual goes into this a bit, and our "What's A Microcontroller?" text would also be helpful.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
You have made it even more clear with your latest advice!
Thanks
Is this the right forum to shamelessly post code and weep?
In the following code, Pin0 goes high for approximately 1 sec when leaving the last subroutine "Fed" and sources enough current to light up an LED.
Pin0 is supposed to be an input and responds as such when the program runs for the first time.
The main "PF_Start" routine does not acknowlege a new High signal on Pin0 to start another cycle and I need to reset the board to make it work. The debug screen shows "start" but it just won't respond to input.
'Motors:
PFServo CON 2 'OUTPUT Pin 2
PFVibe CON 3 'OUTPUT Pin 3
'Sensors
PFEye VAR IN5 'INPUT - Pin5
'Feildpoint I/O
From_FP VAR IN0
To_FP VAR OUT1
'Start Program
PFC_Start: 'Wait for sig from FeildPoint
'From_FP = 0
DEBUG "start",CR
IF From_FP = 0 THEN PFC_Start
DEBUG "From_FP read",CR
PAUSE 1000
GOSUB Feed
Feed: 'Start pellet feed routine
DEBUG "Feed",CR
HIGH PFVibe 'Start vibratory motor
HIGH PFServo 'Send 1us pulse to servo for CW rotation ("HIGH" TO test w/LED)
IF PFEye = 0 THEN Feed 'Is there something in your eye?
DEBUG "PFEye High",CR
PAUSE 1000
GOSUB Fed
GOTO PFC_Start
Fed: 'Pellet fed
DEBUG "Fed",CR
LOW PFVibe 'Vibrator Off
LOW PFServo 'Reverse Servo (LOW to test w/LED)
HIGH To_FP 'Sig to FieldPoint - Pellet Fed
DEBUG "Ping FP",CR
PAUSE 1000
LOW TO_FP
DEBUG "Voltage Here?"
RETURN