通过接收来自键盘或其他输入设备的单字符对BOXZ机器人的两侧手臂动作进行控制。
servoCom()(int keyword);
按键控制机器人的手臂动作。
keyword:整数,按键定义如下:
'u' - 左手抬起;'U' - 左手点动抬起;
'i' - 右手抬起;'I' - 右手点动抬起;
'j' - 左手落下;'J' - 左手点动落下;
'k' - 右手落下;'K' - 右手点动落下;
'o' - 双手抬起;'O' - 双手点动抬起;
'l' - 双手落下;'L' - 双手点动落下;
整体按键布局参考格斗类游戏,配合motorCom()实现对BOXZ的控制。
无返回值
此例程为BOXZ Pro的样例程序。
// BOXZ_Pro // Demo function:The application method to drive the 2x DC motor and 2x Servo // Author:Leo.Zhu // Date:10 Aug, 2013 // https://github.com/leolite/BOXZ // Hardware support list // 1. DFRobot L298 Shield 2A // 2. DFRobot L293 Shield 1A // 3. Adafruit Motor Drive #include "BOXZ.h" int key; void setup() { Serial.begin(9600); boxz.initMotor(); boxz.initServo(); Serial.println("Hello! BOXZ!"); } void loop() { if(Serial.available() > 0) { key = Serial.read(); boxz.servoCom(key); boxz.motorCom(key); } }