|
本帖最后由 LightYear 于 2016-11-19 17:21 编辑
今天收到补发的数据线,给蓝宙补发速度点个赞!!希望以后发货时工作人员用心装配,不要因为一点小瑕疵影响用户的心情。
迫不及待也来写个Altar移动测试,感谢@vickywang的硬件知识科普。
特别说明下,貌似因为产品批次不同或是蓝宙优化了产品设计,我购买的Altar的电机驱动引脚是D5、D6、D9、D10,之前看过@vickywang与@沧海笑1122发的帖子中的电机驱动引脚都是D3、D5、D6、D9,至于哪种设计是新版本就不得而知了。另外请教大伙个问题,不用写pinMode初始化引脚,程序也能正常运行,但看大伙都初始化我也就写上了,但我不懂这是什么意思,求教谁能给我讲讲。[mw_shl_code=c,true]#define LeftForwardPin 5
#define LeftBackwardPin 10
#define RightForwardPin 6
#define RightBackwardPin 9
void setup() {
pinMode(LeftForwardPin, OUTPUT) ;
pinMode(LeftBackwardPin, OUTPUT) ;
pinMode(RightForwardPin, OUTPUT) ;
pinMode(RightBackwardPin, OUTPUT) ;
}
void loop() {
delay(5000);
moveFront();
delay(1000);
moveStop();
delay(1000);
moveBack();
delay(1000);
moveStop();
delay(1000);
moveFrontLeft();
delay(1000);
moveStop();
delay(1000);
moveBackLeft();
delay(1000);
moveStop();
delay(1000);
moveFrontRight();
delay(1000);
moveStop();
delay(1000);
moveBackRight();
delay(1000);
moveStop();
delay(1000);
moveTurnLeft();
delay(1000);
moveStop();
delay(1000);
moveTurnRight();
delay(1000);
moveStop();
delay(1000);
moveStop();
}
void move(int leftForwardSpeed, int leftBackwardSpeed, int rightForwardSpeed, int rightBackwardSpeed) {
analogWrite(LeftForwardPin, leftForwardSpeed);
analogWrite(LeftBackwardPin, leftBackwardSpeed);
analogWrite(RightForwardPin, rightForwardSpeed);
analogWrite(RightBackwardPin, rightBackwardSpeed);
}
//前
void moveFront() {
move(200,0,200,0);
}
//左前
void moveFrontLeft() {
move(150,0,200,0);
}
//右前
void moveFrontRight() {
move(200,0,150,0);
}
//后
void moveBack() {
move(0,200,0,200);
}
//左后
void moveBackLeft() {
move(0,150,0,200);
}
//右后
void moveBackRight() {
move(0,200,0,150);
}
//左旋转
void moveTurnLeft() {
move(0,200,200,0);
}
//右旋转
void moveTurnRight() {
move(200,0,0,200);
}
//停止
void moveStop() {
move(0,0,0,0);
}
[/mw_shl_code]
|
|