Update Steering authored by Adham Beshr's avatar Adham Beshr
......@@ -46,27 +46,4 @@ The **FlexTimer Module (FTM)** is used to generate the required PWM signals. Bel
The function `setServoPosition()` updates the **PWM duty cycle** to control the steering.
```cpp
// Function to set the servo position based on the desired duty cycle
void setServoPosition(float duty_cycle) {
// Update PWM duty cycle for SERVO0 (FTM3 CH6)
FTM_UpdatePwmDutycycle(FTM3_PERIPHERAL, FTM3_FTM_SERVO_CHANNEL, kFTM_EdgeAlignedPwm, duty_cycle);
FTM_SetSoftwareTrigger(FTM3_PERIPHERAL, true); // Apply the new duty cycle
}
// Function to turn the car left
void turnLeft() {
float duty_cycle = 5.0; // 1ms pulse width -> 5% duty cycle
setServoPosition(duty_cycle);
}
// Function to turn the car right
void turnRight() {
float duty_cycle = 10.0; // 2ms pulse width -> 10% duty cycle
setServoPosition(duty_cycle);
}
// Function to center the servo (straight position)
void centerServo() {
float duty_cycle = 7.5; // 1.5ms pulse width -> 7.5% duty cycle
setServoPosition(duty_cycle);
}
```
\ No newline at end of file
![steering code](https://mygit.th-deg.de/ab11885/autonomous-line-following-car-with-camera-based-navigation/-/raw/main/Images/carbon.png)
\ No newline at end of file