I completed the section under Obstacle Avoiding robot and wrote a code to drive it accordingly. But when I uploaded that on Boltduino it does not perform the way it should.
I mean even if I put an object in front of the proximity sensor, it does not make any change to the movement of the robot.
Firstly I don’t know how it performs several other actions other than forward, reverse and left even if they are not written anywhere in the code. Second is direction of robot do not changes when an obstacle comes in the way.
Please help me to solve this issue.
The code which I wrote is :
void forward(){
digitalWrite(4, HIGH);
digitalWrite(12, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
void reverse(){
digitalWrite(4, LOW);
digitalWrite(12, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
}
void left(){
digitalWrite(7, HIGH);
digitalWrite(12, HIGH);
digitalWrite(4, LOW);
digitalWrite(8, LOW);
}
void setup(){
pinMode(11, INPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
}
void loop(){
if(digitalRead(11)==HIGH){
forward();
}
else{
reverse();
delay(1000);
left();
delay(3000);
}
}