diff options
| author | Abel Tim <abel.tim.t@gmail.com> | 2025-03-23 12:38:48 +0100 |
|---|---|---|
| committer | Abel Tim <abel.tim.t@gmail.com> | 2025-03-23 12:38:48 +0100 |
| commit | 764c8722596f5b3bd01bb26848f7289b0972d7b0 (patch) | |
| tree | 73b8090d371b0c0479f1b72803f3e0e0f0754dc1 /CODE/debugprewk/debug/motordriver/softPWM/softPWM.ino | |
| parent | a52c13fdf50fbc19dfdce2d087b4739b96d46a0b (diff) | |
| download | robotica-764c8722596f5b3bd01bb26848f7289b0972d7b0.tar.gz robotica-764c8722596f5b3bd01bb26848f7289b0972d7b0.zip | |
updated repo structure
Diffstat (limited to 'CODE/debugprewk/debug/motordriver/softPWM/softPWM.ino')
| -rw-r--r-- | CODE/debugprewk/debug/motordriver/softPWM/softPWM.ino | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/CODE/debugprewk/debug/motordriver/softPWM/softPWM.ino b/CODE/debugprewk/debug/motordriver/softPWM/softPWM.ino deleted file mode 100644 index ab74715..0000000 --- a/CODE/debugprewk/debug/motordriver/softPWM/softPWM.ino +++ /dev/null @@ -1,46 +0,0 @@ -#include <TimerThree.h> -#include <Arduino.h> - -int pwmPin = 3; - -volatile int PWMval = 0; // PWM value 0-100 - -void setup() { - pinMode(pwmPin, OUTPUT); - Serial.begin(9600); - - Timer3.initialize(800); // 800 microseconds or 1.25kHz - Timer3.attachInterrupt(updatePWM); -} - -void updatePWM() { - static int counter = 0; - - if (counter < PWMval) { - digitalWrite(pwmPin, HIGH); - } else { - digitalWrite(pwmPin, LOW); - } - - counter++; - if (counter >= 100) { - counter = 0; - } -} - -void mcpsoftpwm(int value) { - if (value < 0) value = 0; - if (value > 100) value = 100; - - Serial.print("softPWM pin: 3, value: "); - Serial.println(value); - PWMval = value; -} - -void loop() { - mcpsoftpwm(100); // Set PWM to 100% - delay(1000); - mcpsoftpwm(50); // Set PWM to 50% - delay(1000); - Serial.println("loop"); -} |
