Page 1 of 1

human following robot

Posted: Sat Aug 06, 2016 11:31 pm
by rajatsharma369007
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.
Code: Select all
#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);
  } 
       
}

Re: human following robot

Posted: Sun Aug 07, 2016 9:19 pm
by skimask
I see the problem.

Re: human following robot

Posted: Thu Sep 08, 2016 11:20 am
by stellajohn