With the newly arrived motor in hand, his weeks goal was to get the steering system to a working state. The coding for the steering would of course be far more difficult than on the small RC car due to the use of a standard motor instead of a servo motor.
Earlier this week I made a small update about the calibration process for the car. This process, that is run every time at start-up, serves to establish how long steering from one side to the other will take the car. This information is then set as a variable, and acts a key piece of information for all turning functions within the program.
Today’s new code is that for the steer function. The function takes an input ranging from 0-100 and brings the wheels to that desired position, 0 being full left, 100 being full right, and 50 dead center. To do this, it first divides the Time variable found in the setup by 100, then divides it again by the difference between to current and desired positions. This resulting value sets how long for the wheels to turn. At the end, the desired position is set as the current position to be used for future turns.