Hello, I come back to you because I've try to make the code and I think I'm bad for that. It doesn't work.
I've two infrared sensor, one for the left side, the other one for the right. The left sensor is pluged on A2, the right on A3.
the code in ultrasonic.h:
int Leftsensor=A2;
int Rightsensor=A3;
void loop() {
int Leftdistance = 4800/(analogRead(Leftsensor)-20); //converting in centimeter
int Rightdistance = 4800/(analogRead(Rightsensor)-20);
if (0 < Leftdistance < 20){
strcpy(newCmd,"sit");
}
else if (Leftdistance > 60 or Leftdistance < 0){
strcpy(newCmd,"sit");
}
//same for the right side
}
this code code doesn't work,
in addition I would like those instructions work only when Bittle walk forward
I hope you will help me