OUT command question
Spiral_72
Posts: 791
I'm playing with the BS2....
The following code doesn't work, but I hope it's pretty apparent what I want to do. How else can I do this?
The "1" can actually be different values read from an array.
The following code doesn't work, but I hope it's pretty apparent what I want to do. How else can I do this?
x VAR Byte FOR x=7 TO 4 OUTx = 1 NEXT
The "1" can actually be different values read from an array.
Comments
FOR x=7 TO 4
OUT &h100+x, 1
NEXT X
but in PBASIC I can't find a way to do that just yet.
Actually that was a bad example, but hopefully you still understand the question
OUT0(7) is the same as OUT7 etc.
Thank you! That's brilliant... I spent a lot of time in the manual last night and didn't see this!
If I could find a previous email thread, I'd copy the information related from Mr. Allen on how the I/O bits are treated like an array (maybe he'll read this and comment again).
Regards,
DJ
http://forums.parallax.com/showthread.php?122525-INx-Question&highlight=array+OUT%28
DJ
(The program wont run as is... the data must be loaded into an array first!)
It's a 16 button keypad read routine, which if I have it figured right will report simultaneous button presses. SWEET
I'm trying to make a BigTrak..... just like we used to have as kids.
DIRA = %1111
That before the OUTx commands to those pins will be effective.
Another way to set one row at a time high uses OUTA for pins p0 to p3, and the DCD operator.
IF (INB AND 1) = 1 THEN DEBUG "Button 1 pressed"
......
IF (INB AND 8) = 1 THEN DEBUG "Button F pressed"
I plan to store the operator entered steps in an array, with the first token as a direction, followed by a time from 0-9. I hope to store eight steps, which should be 8*2 nibbles or 16 bytes. Anyways, I suppose that's outside the reason for this post.
Thanks to all for the help!
I hope the syntax is correct (pulling if from memory after having a HUGE lunch! zzZZZZzzzzZZ)
I dunno how to display a hex number, so key "A" shows as 10, "B" as 11 and so on.
I could easily call this routine on demand. I'd probably check periodically for a keypress by bringing all the outputs high, and look for a non-zero on INA, then call this routine if needed.
You can find it here: http://www.parallax.com/tabid/440/Default.aspx
DJ
I'm just happy to be able to help.
DJ