Add PWM motor control and refactor engine update

Introduce ENA pins for both motors and implement rpmToPwm and setMotor.
Replace extensive Serial debug prints with concise motor‑drive logic in
Engine::update. Consolidate sonar pins into a single TRIG_AND_ECHO_PIN.
Update pinMode calls in the sketch to configure the new ENA pins.
This commit is contained in:
2026-06-16 23:35:23 +02:00
parent 17f888a11c
commit 23d5003788
4 changed files with 34 additions and 50 deletions
+3
View File
@@ -36,6 +36,9 @@ public:
int getRPM() const;
int getSpeedKmh() const;
uint8_t rpmToPwm(float rpm);
void setMotor(uint8_t inA, uint8_t inB, uint8_t ena, float rpm, bool reverse = false);
private:
const uint8_t _throttlePin;
const uint8_t _clutchPin;