Code Explanation ServoWrite.ino

Share for us
Share on facebook
Share on twitter
Share on pinterest
Share on whatsapp

Looking at the code folders, you may find that on matter for the app, the obstacle avoidance function or the line following, there is always a sketch ServoWrite.ino. Actually it’s for servo control, so no wonder. You can check the description below for the code. 

Control the servo on pin 2

The program above is for control of a single servo. By setting three parameters including c2, the starting angle, s2, the end angle, and ms0, the rotation speed, we can control the rotating angle and speed of the servo.

Control the servos on pin 4 and pin 7

The program below is for controlling two servos simultaneously. By setting five parameters including the starting angles c4 and c7, the end angles s4 and s7, and the rotation speed ms0, we can control the rotating angle and speed of two servos at the same time.

Control the servos on pin 5, pin 6 and pin 8

Then control three servos simultaneously. By setting seven parameters including the starting angles c5c6, and c8, end angles s5s6, and s8, and the rotation speed ms0, we can control the rotating angle and speed of three servos at the same time.

Control the servos on pin 7, pin 2, pin 4 and pin 8

Next, control four servos simultaneously. Similarly, by setting nine parameters including c7c2c4c8 (starting angles), s7s2s4s8 (end angles), and ms0 (rotation speed), we can control the rotating angle and speed of four servos at the same time. Movements of the RollFlash robot can be well controlled by calling those programs above. Here we just take some examples about different controlling.