Prop I/O question very basic
mikediv
Posts: 825
Hi guys I decided to back up and go the very beginning to learn Spin, please take a look at this code for me..
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'' From Parallax Inc. Propeller Education Kit - 4: I/O and Timing Basics Lab
'' File: ButtonToLed.spin
'' Led mirrors pushbutton state.
PUB ButtonLed ' Pushbutton/Led Method
dira [noparse][[/noparse]6..9] := %1111 ' makes pins outputs
dira [noparse][[/noparse]21..23] := %0000 ' P21-23 → input (this command is redundant)
repeat ' Endless loop
outa [noparse][[/noparse]6..9] := ina [noparse][[/noparse]21..23] ' Copy P21 input to P6 ouput
It works but not how I want it to, I can push each button and it will light up and LED in sequence but what I want it to do is every time I push an input button I wan tit to light up a whole group of pins, so push any button I am using 21-23 and it will turn on prop Pins 6-9 all at the same time ?? Is this possible to do can someone please show me an example. I can even make it simpler.. just use Prop Pin 21 as an input I want to be able to push that button and have it turn on a group of LEDS at the same exact time instead of just one at a time, so push button connected to pin 21 and Prop pins 6,7,8,9 all turn on at the same time ,, thank you
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'' From Parallax Inc. Propeller Education Kit - 4: I/O and Timing Basics Lab
'' File: ButtonToLed.spin
'' Led mirrors pushbutton state.
PUB ButtonLed ' Pushbutton/Led Method
dira [noparse][[/noparse]6..9] := %1111 ' makes pins outputs
dira [noparse][[/noparse]21..23] := %0000 ' P21-23 → input (this command is redundant)
repeat ' Endless loop
outa [noparse][[/noparse]6..9] := ina [noparse][[/noparse]21..23] ' Copy P21 input to P6 ouput
It works but not how I want it to, I can push each button and it will light up and LED in sequence but what I want it to do is every time I push an input button I wan tit to light up a whole group of pins, so push any button I am using 21-23 and it will turn on prop Pins 6-9 all at the same time ?? Is this possible to do can someone please show me an example. I can even make it simpler.. just use Prop Pin 21 as an input I want to be able to push that button and have it turn on a group of LEDS at the same exact time instead of just one at a time, so push button connected to pin 21 and Prop pins 6,7,8,9 all turn on at the same time ,, thank you
Comments
should do what you want
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
Morpheusdual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory IO board kit $89.95, both kits $189.95
Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
Thanks again
Bill I tired it a few different ways it either turns all the leds on with no action on the push buttons or it does nothing here is one of the ways I tried it
PUB ButtonLed ' Pushbutton/Led Method
dira [noparse][[/noparse]4..9] := %111111 ' makes pins outputs
dira [noparse][[/noparse]16..18] := %000 ' P18-21 → input (this command is redundant)
if (ina[noparse][[/noparse]16..18])
outa[noparse][[/noparse]4..9]~~
repeat ' Endless loop
Thanks Mike , sometimes it just seems like some people have way more information than me, I am sure part of it is they are pro's and I am a neewb. But there is some very talented people here it gives me programmer envy lol
Post Edited (mikediv) : 11/20/2009 12:09:49 AM GMT
··http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/WebPM-v1.1.pdf
TrapperBob
·
Andy