|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
最后一题那个智能小车
用Dev运行显示出错误,错误在<Servo.h>,这是为啥啊
#include <Servo.h>
// 为了方便调用,我们为控制左右电机
// 前进后退的数字引脚进行了宏定义
#define LEFT_MOTO_GO 8
#define LEFT_MOTO_BACK 9
#define RIGHT_MOTO_GO 10
#define RIGHT_MOTO_BACK 11
// ...省略部分代码...
void loop()
{
char ch; // 用于接受命令
switch(ch)
{
case 'g':
digitalWrite(LEFT_MOTO_GO, HIGH);
digitalWrite(LEFT_MOTO_BACK, LOW);
digitalWrite(RIGHT_MOTO_GO, HIGH);
digitalWrite(RIGHT_MOTO_BACK, LOW);
break;
case 'b':
digitalWrite(LEFT_MOTO_GO, LOW);
digitalWrite(LEFT_MOTO_BACK, HIGH);
digitalWrite(RIGHT_MOTO_GO, LOW);
digitalWrite(RIGHT_MOTO_BACK, HIGH);
break;
case 'l':
digitalWrite(LEFT_MOTO_GO, LOW);
digitalWrite(LEFT_MOTO_BACK, LOW);
digitalWrite(RIGHT_MOTO_GO, HIGH);
digitalWrite(RIGHT_MOTO_BACK, LOW);
break;
case 'r':
digitalWrite(LEFT_MOTO_GO, HIGH);
digitalWrite(LEFT_MOTO_BACK, LOW);
digitalWrite(RIGHT_MOTO_GO, LOW);
digitalWrite(RIGHT_MOTO_BACK, LOW);
break;
default:
digitalWrite(LEFT_MOTO_GO, LOW);
digitalWrite(LEFT_MOTO_BACK, LOW);
digitalWrite(RIGHT_MOTO_GO, LOW);
digitalWrite(RIGHT_MOTO_BACK, LOW);
break;
}
// ...省略部分代码...
}
怎么改也运行不了的,他应该就是让你明白这个switch结构
|
|