IO control
The main function of this JavaScript code is to initialize a robot connected to a port and perform some initial settings for it. Specifically, the code uses the mycobot library to control the robot and performs the following operations:
Connect the robot: Connect to the robot by specifying the serial port (COM15) and baud rate (115200).
Set the color of the robot's indicator light: Set the color of the indicator light by specifying three color values (125, 11, 9) for red, green, and blue.
Initialize the position of the robot: Set the current angle and coordinates of the robot as the starting point of the robot's operation.
<!-- Initialization program -->
const mycobot = require('mycobot')
const obj = mycobot.connect('COM15',115200)
<!-- Set the ATOM indicator color mycobot.setColor(redValue,greenValue,blueValue)-->
<!-- Note: The three parameters are limited to 0~255 -->
obj.write(mycobot.setColor(125,11,9))
<!-- Set the current robot arm angle and coordinates to the robot arm operation starting point -->
obj.write(mycobot.setGripperInit())