我看著書的解說,設計一個超音波避障車,結果車子只會前進幾秒,後退幾秒,右後轉,一直重複,請問我哪裡打錯,我是新手海請各位高手幫幫忙。
#include <Servo.h>
Servo servo;
const int ECHOPIN=2;
const int TRIGPIN=4;
const int negR=7;
const int posR=8;
const int negL=12;
const int posL=13;
const int pwmR=5;
const int pwmL=6;
const int Rspeed=150;
const int Lspeed=150;
const int rotSpeed=180;
unsigned long Rdistance;
unsigned long Ldistance;
unsigned long Cdistance;
void setup()
{
pinMode(posR,OUTPUT);
pinMode(negR,OUTPUT);
pinMode(posL,OUTPUT);
pinMode(negL,OUTPUT);
pinMode(TRIGPIN,OUTPUT);
pinMode(ECHOPIN, INPUT);