All Tutorials / DJ Sures / Control Meccano Meccanoid

Control Meccano Meccanoid

EZ-Builder Code

The EZ-B will now send commands to the Arduino over Serial at 9600 using the first UART port. Of course, you can change that UART to any other UART of the EZ-B v4, as long as you update the script.

Here is an example ez-script to move the left shoulder to 90 degrees.

Code:


UARTInit(0, 0, 9600)

definearray($mecaSend, 3)

$mecaSend[0] = 0x01 # move servo
$mecaSend[1] = 0x00 # LEFT_ARM_PITCH
$mecaSend[2] = 90 # 90 degrees

UARTWriteBinary(0, 0, $mecaSend)



Here is an example ez-script to change the color of the right shoulder to red.

Code:


UARTInit(0, 0, 9600)

definearray($mecaSend, 3)

$mecaSend[0] = 0x00 # change color
$mecaSend[1] = 0x05 # RIGHT_ARM_PITCH
$mecaSend[2] = 0xf1 # JOINT_RED

UARTWriteBinary(0, 0, $mecaSend)



*Note: in the examples, the UARTInit() is called for each example. This command only needs to be called one time. It is only placed in each example to demonstrate the UART initialization command. You can place this command in your CONNECT script for the EZ-B. The CONNECT script is located in the connection control by pressing the GEAR icon.