# The Design and Building of a Hexapod Robot with Biomimetic Legs
## 5. Mechatronics of the Control System  
Following the analysis and construction of the mechanism, the mechatronics of the control system (Figure 14), consisting of a microcontroller, drivers, sensors, and motors with gear trains, was built. Figure 14. Block diagram of mechatronic system. Figure 13. The robot changes its azimuth through a series of motions where the legs of the bottom deck and the upper deck are labeled as 1 and 2, respectively, while the red circles stand for the legs standing statically on the ground. (**a**) Initial posture. (**b**) The upper deck suspends its legs and makes a swing \(15^{\circ}\) clockwise, while the legs of the bottom deck stay on the ground. (**c**) The bottom deck suspends its legs and makes a swing \(30^{\circ}\) clockwise, while the legs of the upper deck stay on the ground. (**d**) The upper deck suspends its legs and makes a swing \(15^{\circ}\) clockwise, while the legs of the bottom deck stand on the ground. This part mainly controls the orientation of the swivel and the motions of the TJLs, with a phase of 180\({}^{\circ}\) between the two sets of cranks. The Arduino was chosen as the microcontroller for this project. Since the first Arduino [27] was introduced in 2005, it has become one of the most popular microcontrollers used by engineers and even large corporations. The appealing features of Arduino are mostly its openness and ease-of-use. It is worth mentioning that the programming of an embedded system is done according to cross-development principles, so that the code can run on a target boar, different from the one where the code was built. The Arduino provides an integrated development environment (IDE) for users to edit, debug, and compile their application programs on a personal computer and then upload them to the Arduino board for execution. In Figure 15, the crank of the TJL is attached through four metal blades, evenly partitioning the circumference into four quarters. The proximity sensor, CHIIB LJ18A3-10-Z/BY, is used to detect four phases of the crank, based on which the Arduino is able to keep the two sets of cranks apart, at 180\({}^{\circ}\), during operation. Regarding the control of the swivel (Figure 16), specific care needs to be taken to avoid mechanical collision. First, one system, consisting of a proximity sensor, CHIIB LJ12A3-4-Z/BY, and three metal blades, is installed to receive feedback on the azimuth of the swivel. Second, another system, using two limited switches as a safety guard to assure that the range of operation is maintained, is installed. When the swivel reaches its maximum range, it will push the leverage of the limited switch, so as to cut off the power of the swivel motor immediately. Without the safety guard system, the catastrophe of a mechanical collision is inevitable in developing the application programs. Regarding the DC motors, there are two motors with specifications of 12 V, 2 A, 35 W, 30 rpm, and 25.47 kg-cm, used for the TJLs and one motor with specifications of 12 V, 2 A, 35 W, 10 rpm, and 76.4 kg-cm, used for the swivel. The drivers are all in typical H-bridge with specifications of 12-36 V, 10 A, and 120 W.  
In this project, Bluetooth (BT) was used to establish wireless communication between the computer and the Arduino. Bluetooth is a wireless technology standard, IEEE 802.15.1, for exchanging data between fixed and mobile devices over short distances, most often within 10 m, using short-wavelength  
Figure 16: Sensor system to detect the azimuth of the swivel and the safety guard system. Figure 15: Sensor system to detect the phases of the crank. UHF (Ultra High Frequency) radio waves, in the industrial, scientific and medical radio bands, from 2.400 to 2.485 GHz, and in personal networks. AT (Attention), commands are instructions used to control a modern. Every command line starts with \"AT\" or \"at,\" which is why modem commands are called AT commands.