Hm, now is clear why don't work !
It's possible to refresh this status ? I guess not ..
Or it's another way to get results ?
Sorry I am so dumb ...
Hm, now is clear why don't work !
It's possible to refresh this status ? I guess not ..
Or it's another way to get results ?
Sorry I am so dumb ...
LE : Solution (not so elegant, but working) :
Code:Main: ;reading buttons on row 1 PortA.0 = 0 TrisA.1 = 1 pause 10 if porta.2 = 0 then portb.1 = 1 while porta.2=0 : wend portb.1 = 0 endif if porta.3 = 0 then portb.2 = 1 while porta.3=0 : wend portb.2 = 0 endif if porta.4 = 0 then portb.3 = 1 while porta.4=0 : wend portb.3 = 0 endif PortA.0 = 1 TrisA.1 = 0 ;reading buttons on line 2 Portb.0 = 0 TrisA.1 = 1 pause 10 if porta.2 = 0 then portb.4 = 1 while porta.2=0 : wend portb.4 = 0 endif if porta.3 = 0 then portb.5 = 1 while porta.3=0 : wend portb.5 = 0 endif if porta.4 = 0 then portb.6 = 1 while porta.4=0 : wend portb.6 = 0 endif Portb.0 = 1 TrisA.1 = 0 Goto main
Hi,Of course there is, same way as you got the status in the first place, here with a little twist:It's possible to refresh this status ? I guess not ../Henrik.Code:Main: GOSUB GetStatus ' Get inital state Select Case status_1 Case 12 PortB.1 = 1 WHILE status_1 = 12 GOSUB GetPortStatus ' <--- Now we'll update status_1 so we know when the button is released. WEND PortB.1 = 0 '.... And so on '.... and so on '.... and so on Goto Main GetPortStatus: status_1 = PortA & %00011100 RETURN
Wow ! Nice ! Thanks !
How far am I from this technique...
Just stick with it.
Make sure you always try to really think what's going on, think what the program is actually doing and what the cause of that is.
Like, OK, when the value of this or that variable is 12 I'm going to loop around here untill the value is no longer 12 - that's fine. What makes the variable change value? Well nothing because I'm not evaluating anything within the loop. Duh, I need to make sure the value CAN change by reading the port and evaulate the result WITHIN the loop, not outside of it....
/Henrik.
Bookmarks