diff options
| author | Abel Tim <abel.tim.t@gmail.com> | 2026-02-08 10:52:55 +0100 |
|---|---|---|
| committer | Abel Tim <abel.tim.t@gmail.com> | 2026-02-08 10:52:55 +0100 |
| commit | 282231ea2829d286ae3432022d56a6c4f573ed33 (patch) | |
| tree | 41f9785885f60a4d45253453988f6b30390aa8b7 /code/debug/motors/pwm/pwm.ino | |
| parent | a320df8fb9789016b17e98b019f32cff31e31773 (diff) | |
| download | robotica-282231ea2829d286ae3432022d56a6c4f573ed33.tar.gz robotica-282231ea2829d286ae3432022d56a6c4f573ed33.zip | |
SOFTPWM
Multi-line description of commit,
feel free to be detailed.
[Issue: X]
Diffstat (limited to 'code/debug/motors/pwm/pwm.ino')
| -rwxr-xr-x | code/debug/motors/pwm/pwm.ino | 38 |
1 files changed, 38 insertions, 0 deletions
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 <SoftPWM.h> + +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); +} |
