From 282231ea2829d286ae3432022d56a6c4f573ed33 Mon Sep 17 00:00:00 2001 From: Abel Tim Date: Sun, 8 Feb 2026 10:52:55 +0100 Subject: SOFTPWM Multi-line description of commit, feel free to be detailed. [Issue: X] --- code/debug/motors/pwm/pwm.ino | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 code/debug/motors/pwm/pwm.ino (limited to 'code/debug/motors/pwm/pwm.ino') diff --git a/code/debug/motors/pwm/pwm.ino b/code/debug/motors/pwm/pwm.ino new file mode 100755 index 0000000..9743b09 --- /dev/null +++ b/code/debug/motors/pwm/pwm.ino @@ -0,0 +1,38 @@ +#include + +int m1enA = LED_BUILTIN; +int m1enB = 5; +int m1pwm1 = 4; +int m1pwm2 = 3; +int m1encoA = 32; +int m1encoB = 31; + +void setup() { + Serial.begin(9600); + + SoftPWMBegin(); + SoftPWMSetPolarity(m1enA, 0); + SoftPWMSet(m1enA, 0); + + pinMode(m1enB, OUTPUT); + pinMode(m1pwm1, OUTPUT); + pinMode(m1pwm2, OUTPUT); + + pinMode(m1pwm1, INPUT); + pinMode(m1pwm2, INPUT); + +} + +void loop() { + SoftPWMSet(m1enA, 50); + digitalWrite(m1enB, LOW); + digitalWrite(m1pwm1, HIGH); + digitalWrite(m1pwm2, LOW); + delay(500); + SoftPWMSet(m1enA, 255); + digitalWrite(m1enA, HIGH); + digitalWrite(m1enB, LOW); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, HIGH); + delay(500); +} -- cgit v1.2.3