In EZ-Builder, add a new EZ-Script control.
This code will be pasted into the EZ-Script control. The code will loop and continue to request the interrupt counts of the encoders from the Arduino.
The values of the encoder are in the array $encoders and $encoders. You may use these two values globally within the project to identify what the encoder values are.
uartinit(0, 0, 9600)
# Send a request for data to the arduino
uartwrite(0, 0, "a")
# wait a bit for the data to be transmitted
$dataAvail = UartAvailable(0, 0)
IF ($dataAvail != 2)
print("The arduino didn't send us anything. Exiting")
UartReadBinary(0, 0, 2, $encoders)
print("Encoder A: " + $encoders)
print("Encoder B: " + $encoders)