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/src/main.cpp | |
| 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/src/main.cpp')
| -rw-r--r-- | code/debug/motors/PWM/src/main.cpp | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/code/debug/motors/PWM/src/main.cpp b/code/debug/motors/PWM/src/main.cpp deleted file mode 100644 index c7d8fe0..0000000 --- a/code/debug/motors/PWM/src/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include <Arduino.h> - -IntervalTimer myTimer; - -int pwmPin = 3; //pin for PWM output -int pwmacc = 1000; //how accurate the PWM is, means you can enter value from 0 to the value of pwmacc -int PWMval = 0; //value of the PWM, means you can enter value from 0 to the value of pwmacc - - -void setup() { -} -void setup() { - - Timer3.initialize(800); // 800 microseconds or 1.25Hz - Timer3.attachInterrupt(updatePWM); -} - -void updatePWM() { - static int counter = 0; - if PWMval < 0) { - PWMval = 0; - } - if (PWMval > pwmacc) { - PWMval = pwmacc; - } - - if (counter < PWMval) { - digitalWrite(pwmPin, HIGH); - } else { - digitalWrite(pwmPin, LOW); - } - - counter++; - if (counter >= pwmacc) { - counter = 0; - } -} - -void loop() { - for i (0; i < pwmacc; i++) { - PWMval = i; - delay(10); - } - for i (pwmacc; i > 0; i--) { - PWMval = i; - delay(10); - } -}
\ No newline at end of file |
