Word register (maybe not the right description)

Chavaquiah

Senior Member
with me so far?
Yes. I have a Nespresso and I'm not affraid to use it. :p


attached is
Is it? :confused:

OK, I'll get serious now.

Use a shadow word variable to keep the state of each button. Then XOR the read state with that shadow.

Code:
symbol Lights = w1
symbol Buttons = w0

init:
   Lights = 0  ' all lights off

main:
   ' ...
   ' Read buttons
   ' ...
   [B]Lights = Lights XOR Buttons[/B]
   ' Output Lights
   goto main
 

hippy

Ex-Staff (retired)
Staff member
Your what you have so far attachment appears to be missing :)

Try running this code through the simulator, it simulates the SetLed code ( input buttons in w0, leds lit in w3 ) and you can only control 8 input buttons, but it should give the general idea -

Code:
#Picaxe 20M

Do
  w0 = pins
  Gosub SetLeds
  pins = w3
Loop

SetLeds:
  w2 = w0 ^ w1 & w0
  w1 = w0
  w3 = w3 ^ w2
  Return
 

MPep

Senior Member
Poor manners

@QuIck,

It is bad form to remove the original question!
This does not help anybody at all. If you have found the answer, please be kind enough to actually show it. I am sure that others would have had a similar question and benefitted from the answer.

MPep.
 
Top