Asked — Edited

Numeric Keypad - Mobile Builder

Good Afternoon,

I am looking to create a numeric keypad within ARC. I want to pre-program a script for example 133. How do you combine the numbers into a string value, and that value is a number?

Thanks WayneA


ARC Pro

Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

#9  

Thank You Rich. You have been a big help.

#10  

@VGosine Yes, a future project would be to expand on this keypad to do calculations. Do you have any ideas on how it could be done?

#11  

@rich I tried to use your code, it is way over my head. Thank You for the help, I got to break down your code and try to understand it a bit better.

Trinidad/Tobago
#12  

@WayneA if you wanted to do calculations with the number stored you would need to setup variables that would store a number entered, it would then store another variable for the operation when the operation is entered it would reset the buttons for entering a new number.

When i have some time i will see if i could come up with a similar interface and share the project with you.

United Kingdom
#13  

@WayneA, I don't know how I can break the code down further for you. Which part(s) are you struggling to get your head around?

#14  

I guess I do not understand the sequences that you have set up. I guess my thinking process is that for each button that is pressed, the script within the button is checking the running script to see if any other button is pressed. If it is, the button script knows how to handle.

Another thought that I had was to to just setup a string value, lets say $N. Create my 10 buttons and each press of the button would make the string value of $N = "1". Every time the $N value changed store that into another string separated by commas. Depending the amount of commas and the amount of numbers contained in the string, the output would equal to for example "444".

Then, another thought I had was to shift the string value down. (I am taking an online course to help me get the basics of code - Covering Left Shift Bits and Right Shift Bits.)

Then another thought was to re write my project to just press a button and CC("444", scriptstart )

United Kingdom
#15  

Make 10 script buttons in the mobile interface, label them 0 to 9

For each button have a script like this one (this example is for number 4)


IF($sequence = 1)
$keycode = 4000
$sequence = 2
Halt()
ElseIf($sequence = 2)
$keycode = $keycode + 400
$sequence = 3
Halt()
ElseIf($sequence = 3)
$keycode = $keycode + 40
$sequence = 4
Halt()
ElseIf($sequence = 4)
$keycode = $keycode + 4
$sequence = 0
Halt()
Else
SayEZB("There has been an error")
EndIf

To change for other numbers simply replace the 4000, 400, 40 and 4 for whichever number you are writing the script for. I.E. For number 2 use 2000, 200, 20 and 2. For 1 use 1000, 100, 10 and 1.

After each button press the sequence is increased so the scripts will know what value to add to the keycode.

You also need the script running that will trigger the requested scripts or actions when the code is sent to it. That's the other script I posted. You could have up to 10,000 different scripts or actions triggered which would require 10,000 IF statements. Obviously I haven't included all 10,000!

This is the script.


:loop
WaitFor($sequence = 0)
IF($keycode = 0)
# Run action for 0000
ElseIf($keycode = 1)
# Run action for 0001
...
ElseIf($keycode = 4444)
# Run action for 4444
ElseIf($keycode = 4445)
# Run action for 4445
...
ElseIf($keycode = 9998)
# Run action for 9998
ElseIf($keycode = 9999)
# Run action for 9999
Else
SayEZB("There has been an error")
EndIf
Sleep(200)
$sequence = 1
Goto(loop)

When the sequence in the number scripts is complete it resets the $sequence variable to 0. The above code waits for that to become 0 and then checks the sequence and runs the code between that sequences ELSEIF and the next ELSEIF. If the code doesn't match it runs the ELSE code so you needn't do all 10,000 statements.

At the end of the above code it resets the sequence to 1 again so the keypad code number scripts know the digit position. It then loops back to the start and waits for the sequence to be set as 0 again before it moves past the WaitFor line.

Most of the work is done for you above you just need to change the script for each number for the keypad code and fill in the ControlCommands in the second script above.

#16  

Thank You Rich, one more question, when the script runs, the order of numbers is wrong, for instance, if I click 732, the string value is 237, anyway to make outcome in the right order?