Found out how to debug so I will not post the code, but here are the results. I tried to be descriptive in the debug comments so 'Begin Loop' is at the beginning of the 'void Loop()' or right before and after a decision or action like the 'rightMotorStop();' part of the code that should stop the servo if it is run. What it is currently showing is that the functions
void leftMotorStop()
{
digitalWrite(7, LOW);
}
void rightMotorStop()
{
digitalWrite(6, LOW);
}
are not coded correctly. I thought a LOW signal would turn off the input to the pins and stop the servos. How should these be coded?
Begin Loop
After inches and cm calculations
4in, 11cm
0 chkDistanceFwd 10 dangerThresh
Between serial print and lcd print
Before ping and compare (cm>dangerThresh)
if (cm>dangerThresh) //if the path is clear
leftMotor.write(LForward); //move forward
rightMotor.write(RForward); //move forward
Begin Loop
After inches and cm calculations
4in, 10cm
0 chkDistanceFwd 10 dangerThresh
Between serial print and lcd print
Before ping and compare (cm>dangerThresh)
else //if path is blocked
rightMotorStop(); //stops servo***** NOT WORKING
leftMotorStop(); //stops servo***** NOT WORKING
Before ping and compare chkDistanceFwd = cm
Before (chkDistanceFwd<=dangerThresh)
if (chkDistanceFwd<=dangerThresh) //if center object is <= minimum programmed distance)
After if (chkDistanceFwd<=dangerThresh) //if center object is <= minimum programmed distance
After ping and compare chkDistanceFwd = cm
Begin Loop
After inches and cm calculations
3in, 9cm
10 chkDistanceFwd 10 dangerThresh
Between serial print and lcd print
Before ping and compare (cm>dangerThresh)
else //if path is blocked
rightMotorStop(); //stops servo
leftMotorStop(); //stops servo
Before ping and compare chkDistanceFwd = cm
Before (chkDistanceFwd<=dangerThresh)
if (chkDistanceFwd<=dangerThresh) //if center object is <= minimum programmed distance)
After if (chkDistanceFwd<=dangerThresh) //if center object is <= minimum programmed distance
After ping and compare chkDistanceFwd = cm
Begin Loop
After inches and cm calculations
2in, 7cm
9 chkDistanceFwd 10 dangerThresh
Between serial print and lcd print
Before ping and compare (cm>dangerThresh)
else //if path is blocked
rightMotorStop(); //stops servo
leftMotorStop(); //stops servo
Before ping and compare chkDistanceFwd = cm
Before (chkDistanceFwd<=dangerThresh)
if (chkDistanceFwd<=dangerThresh) //if center object is <= minimum programmed distance)
After if (chkDistanceFwd<=dangerThresh) //if center object is <= minimum programmed distance
After ping and compare chkDistanceFwd = cm