该代码似乎并不工作,但我也刚开始学习如何编写代码的Arduino。 我试图运行两个直流电动机和一个伺服转向作为一个机器人车。 我应该怎样赖特它,所以它的工作原理。 所有我想要做的是使用两个马达向前驱动汽车和伺服为汽车提供方向。 我怎样才能改善这种代码?
#include <Servo.h>
int servoRightPin = 2;
int servoLeftPin = 3;
int servoDirPin = 4;
Servo servoRight;
Servo servoLeft;
Servo servoDir;
void turnLeft()
{
servoDir.write(0.6);
delay(300000);
servoLeft.write(180);
servoRight.write(0);
}
void moveForward()
{
servoDir.write(0);
delay(240000);
servoLeft.write(180);
servoRight(0);
}
void turnLeft()
{
servoDir.write(0.6);
delay(300000);
servoLeft.write(180);
servoRight.write(0);
}
void moveForward()
{
servoDir.write(0);
delay(240000);
servoLeft.write(180);
servoRight(0);
}
june_4_car.ino: In function 'void moveForward()':
june_4_car.ino:25:15: error: no match for call to '(Servo) (int)'
june_4_car.ino: In function 'void turnLeft()':
june_4_car.ino:28:6: error: redefinition of 'void turnLeft()'
june_4_car.ino:12:6: error: 'void turnLeft()' previously defined here
june_4_car.ino: In function 'void moveForward()':
june_4_car.ino:36:6: error: redefinition of 'void moveForward()'
june_4_car.ino:20:6: error: 'void moveForward()' previously defined here
june_4_car.ino:41:15: error: no match for call to '(Servo) (int)'
Error compiling.