Not to pick apart your code, but it is overly complicated for the simple task at hand.
None of this is more so true then your keypad. For your 21 lines of code, I was able to do the same, with more functionality. (can handle more then 4 digits)
Code:
N@ Numpad
I@ Input Reset
O@ Value
Input -> Value = Value * 10 + ( Input -1);
Reset -> Value = 0;
All buttons are not toggled. Button 1 = (0,2), Button 2 = (0,3), Button 3 = (0,4), ... Button 9 = (0,10), Button 0 = (0,1) and of course, Reset = (0,1);
The only problem this has is with large numbers. It stops doing math correctly which I suspect is a limitation of the lua.
Edit: Forgot to mention how to wire it up... Reset goes to Reset, Buttons 1-5 to one add chip, the first add chip and buttons 6-0 to another add chip, and then that final add chip is wired to Input
(1) (2) (3) (4) (5) -> ADD1 (6) (7) (8) (9) (0) -> INPUT
Bookmarks