i have some problem in robot while turning it right. i am using 2 pir sensor and 1 distance sensor. when the right pir is giving signals then the left motor is not responding and it moves only when left pir is also giving signals along with right.
#include<AFMotor.h>
AF_DCMotor myMotor2(2);
AF_DCMotor myMotor1(1);
int pirPin2 = 9;
int pirPin1 = 8;
byte motorSpeed = 0;
byte motorSpeedMax = 255;
byte motorSpeedMin = 0;
void setup(){
Serial.begin(9600);
pinMode(pirPin1, INPUT);
pinMode(pirPin2, INPUT);
digitalWrite(pirPin1, HIGH);
digitalWrite(pirPin2, HIGH);
}
void loop(){
if(digitalRead(pirPin2) == HIGH){
myMotor2.run(FORWARD);
myMotor2.setSpeed(255);
}else{
myMotor2.setSpeed(0);
}
if(digitalRead(pirPin1) == HIGH){
myMotor1.run(FORWARD);
myMotor1.setSpeed(255);
} else{
myMotor1.setSpeed(0);
}
}