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
+7 -3
View File
@@ -8,8 +8,7 @@ const byte AUTH_UID[4] = { 145, 136, 97, 102 };
const byte AUTH_UID_SIZE = sizeof(AUTH_UID);
// // Odległościomierz
// const int TRIG_PIN = 6;
// const int ECHO_PIN = 5;
const int TRIG_AND_ECHO_PIN = 3;
const long SONAR_MAX_DIST_CM = 400;
@@ -30,7 +29,12 @@ const uint8_t BRAKE_PIN = A2;
const uint8_t THROTTLE_PIN = A3;
// Silniki
// Prawy silnik
const int IN_1 = 9;
const int IN_2 = 8;
const int ENA_1 = 5;
// Lewy silnik
const int IN_3 = 4;
const int IN_4 = 3;
const int IN_4 = 2;
const int ENA_2 = 6;