while (true)
{
//Get Ping Distance (front of car)
ForwardDistance = ForwardPing.GetDistance(Parallax.Components.Ping.DistanceUnits.Inches);
Debug.Print(ForwardDistance.ToString());
//Drive forward while distance is 2ft or more, drive forward and straight
//When closer than 2ft back up and turn, then repeat
if (ForwardDistance >= 24)
{
Futaba.SetPosition(100);
Rooster.Drive();
}
else //Stop car, turn wheels to the left, reverse for one second at lowest speed
{
Rooster.Stop(); // this doesnt exactly stop, just cuts motor drive, so it may still ram into things
Futaba.SetPosition(80);
Rooster.Reverse();
Thread.Sleep(1000);
}
}