The servo moves the arm between 30 and 90 degrees angle (defined in the server settings file located in the dirapp folder littlecrane.set [a map]).
Depending on the servo used, pressing multiple times on a move button might be required to move the crane arm (ToDo: test with another servo type).
If the servo is not moving, its starts to jitter. To avoid jittering, the servo motor is detached and attached again when pressing a move button.
Note: there are various threads in the Arduino forums about this problem; tried several solutions where as detach and attach works best.
The B4J server is running on a Raspberry Pi, which has an Arduino connected via an USB port (/dev/ttyACM0).
The server sends array of bytes to the Arduino: byte 0 = servoid (in case more then one servo = future thinking), 1 = angle position, 2 = 0 to set new angle or 1 to request angle position.
The Arduino receives the data via Asyncstream, acts accordingly and sends the update position (in JSON format) back to the server which updates the connected browser (Crane Position, this was a tricky one to solve = ConnectedBrowsers.Keys and CallSubDelayed).
Instead of JSON format, it is also possible to use array of bytes instead.
This experiment open for any creative enhancements (like additional servos, use slider to move arm) esp. using Lego Technic.