how can i use Me 4-Button to execute a logical piece of code. I am trying to execute 6 blocks based on a combination of Key presses like 1-2, 1-3, 1-4, 2-1, 2-3, 2-4. The problem is when 1 execute 1-2 key combination, Key-2 is pressed so the code will execute 2-1 if i press Key 1 now. I want to reset the key pressed event, so that i should be able to restart reading of the key pressed event.
Me 4-button clear the last button state
Please show us your code. It is hard to help with problems without seeing what you are working with.
Mike
i am attaching the short code below. if i press key 1 and then key 2, now the first block is executed and then ,if i press key 3 it will execute the code for 2-3. basically instead of doing Key 1 - Key 2 and then waiting for user to press Key 2 again and then - Key 3 it already assumes Key -2 is pressed for the second sequence.
Okay, here is what I came up with. ButtonState.sb2 (75.2 KB)
The problem is that the processor is faster then the fingers, and nothing keeps track of all the button pressing. In your code, once key1 is pressed it waits for key2 to be pressed. When you press key2, it executes that part of the code and continues through to the ELSE, before you have time to take your finger off key2. Now it is waiting for key3 to be pressed before it starts the loop again.
In my example, it will not matter how slow your fingers are, any key pressed will set it’s value to 1 and increment kSum. After the second key is pressed, it’s value will be set, and increment kSum again. When kSum has a value of 2, the last if will be true, and execute the Logic block to set the LEDs, then execute the Reset block to set all of the variables back to 0.
The ‘repeat until’ is used to wait until your finger is off the button before proceeding.
Unfortunately, I could not find my 4-Button to test out my code. I hope this will at least give you some ideas to try if it does not work correctly.
Good luck and let me know how it goes.
Mike