summaryrefslogtreecommitdiff
path: root/code/debug/motors
diff options
context:
space:
mode:
Diffstat (limited to 'code/debug/motors')
-rw-r--r--code/debug/motors/3m_test/.gitignore5
-rw-r--r--code/debug/motors/PWM/.gitignore5
-rw-r--r--code/debug/motors/PWM/src/main.cpp43
-rw-r--r--code/debug/motors/base_drive/.gitignore5
4 files changed, 38 insertions, 20 deletions
diff --git a/code/debug/motors/3m_test/.gitignore b/code/debug/motors/3m_test/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/motors/3m_test/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/debug/motors/PWM/.gitignore b/code/debug/motors/PWM/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/motors/PWM/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
diff --git a/code/debug/motors/PWM/src/main.cpp b/code/debug/motors/PWM/src/main.cpp
index 7564056..53369e4 100644
--- a/code/debug/motors/PWM/src/main.cpp
+++ b/code/debug/motors/PWM/src/main.cpp
@@ -1,13 +1,46 @@
-#include "SoftPWM.h"
#include <Arduino.h>
-int pwmPin = 3;
+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() {
- SoftPWMBegin();
+
+ 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() {
- SoftPWMSetFadeTime(pwmPin, 2500, 2500);
- delay(1000);
+ 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
diff --git a/code/debug/motors/base_drive/.gitignore b/code/debug/motors/base_drive/.gitignore
deleted file mode 100644
index 89cc49c..0000000
--- a/code/debug/motors/base_drive/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch