read 3 buttons in parallel
sicoloco55
Posts: 6
I have 3 buttons and i want to read the pulse in 3 different pins... but in parallel
i think how to but my code dosen't work
here is what i do
i think how to but my code dosen't work
here is what i do
CON _clkmode = rcfast high = 1 low = 0 out = %111 in = %000 VAR BYTE cogIzq BYTE cogDer BYTE cogCen LONG stack0[20] LONG stack1[20] LONG stack2[20] PUB Start dira[0] := 1 dira[1] := 1 dira[2] := 1 dira[3] := 0 dira[4] := 0 dira[5] := 0 cognew(girarizq(0,3),@stack0) cognew(girarder(1,4),@stack1) cognew(centrar(2,5),@stack2) PRI girarizq(Pin, Puls1) repeat while true if ina[Puls1] == high outa[Pin] := high PRI girarder(Pin, Puls2) repeat while true if ina[Puls2] == high outa[Pin] := high PRI centrar(Pin, Puls3) repeat while true if ina[Puls3] == high outa[Pin] := high
Comments
Maybe this will help... But I am not sure I completely understand what you are wanting to do...
so... i have 3 pulses pin 3, pin 4 and pin 5 i need to check the 3 of them at the same time
i simulate the movement of the crane with 3 leds if pin 3 is high the left leds goes on and so one...
Do you need each button to go into a different cog to run completely independently?
If not you can have one cog read all the buttons then start other cogs to carry out actions.
The code here should read the port pins then shift the bits to align with the out put pins and set them.
I am however new to propeller! I just got a demo board but don't have it with me as I am in Malaysia this week, but live in England so I have not tried this code!!
So if I wanted to read the port and write it in just one cog would my code be correct if I move the dira statement?
Does spin manage the bit operations in outa[0..2] := ina[3..5] >> 3 or would I need individually test and set the bits?
Many thanks for your assistance!
(I have many years of programming experience in PIC16, 18 and 24 in assembler and C, so I have to learn to think differently for the Propeller.).
Andy