More Power and Sharper Coding for the RC Car

After all of the modifications and fixes of the self driving  RC car,     Mr. Bahn introduced me into a much more efficient way of coding and programming for the car. It all came down into creating different “if” statements, because my statements were over lapped and the sensors were shooting data back to create two commands at once for the car, and it would cause the car to get stuck in between two commands. The solution to this problem of the car glitching out came down to starting fresh and drawing a chart out with 6 different regions that the sensors can see. With this sketch below it developed a much better understanding of what commands will be needed to have the car avoid obstacles to its possible best doing. The Sensors are related to each other in the if statements now as well, for example if the right sensor is reading the distance is closer than the left, the car will turn left. A delay in the void loop was needed to slow the reaction of the commands down a split second so the car could back up to the left or right rather than getting stuck in between two if statements. There has also been a new sensor mount out on the front of the car now, this will hopefully create a more consistent reading of the distance away from obstacles. The sensors readings are now pulled from an average of 5 readings now to prevent odd crazy numbers being thrown to the car to act upon, this is a program called smoothing  under File>Examples>Analog>Smoothing. The motor driver is also powered from a heavier, but more reliable battery giving the motor driver 7.2 V to work with. I’m expecting the car to be avoiding obstacles very consistently by the end of the week.

 

Leave a Reply

Your email address will not be published. Required fields are marked *