]> kolegite.com Git - vmks.git/commitdiff
Added a simple DC motor example
authorVladimir Garistov <vl_garistov@gmail.com>
Fri, 26 Nov 2021 09:17:17 +0000 (11:17 +0200)
committerVladimir Garistov <vl_garistov@gmail.com>
Fri, 26 Nov 2021 09:17:17 +0000 (11:17 +0200)
Examples/DC_motor_speed_control/DC_motor_speed_control.ino [new file with mode: 0644]
Examples/DC_motor_speed_control/DC_motor_speed_control.png [new file with mode: 0644]
Examples/DC_motor_speed_control/tinkercad_link.txt [new file with mode: 0644]

diff --git a/Examples/DC_motor_speed_control/DC_motor_speed_control.ino b/Examples/DC_motor_speed_control/DC_motor_speed_control.ino
new file mode 100644 (file)
index 0000000..086bee0
--- /dev/null
@@ -0,0 +1,21 @@
+#define DRV_IN1        11
+#define DRV_IN2        10
+#define DRV_EN 12
+#define POT            A0
+
+void setup()
+{
+    pinMode(DRV_IN1, OUTPUT);
+       pinMode(DRV_IN2, OUTPUT);
+       pinMode(DRV_EN, OUTPUT);
+       pinMode(POT, INPUT);
+       digitalWrite(DRV_IN1, LOW);
+       digitalWrite(DRV_IN2, LOW);
+       digitalWrite(DRV_EN, HIGH);
+}
+
+void loop()
+{
+       // Instead of /4, map() or >>2 can be used.
+       analogWrite(DRV_IN1, analogRead(POT) / 4);
+}
diff --git a/Examples/DC_motor_speed_control/DC_motor_speed_control.png b/Examples/DC_motor_speed_control/DC_motor_speed_control.png
new file mode 100644 (file)
index 0000000..c8eb609
Binary files /dev/null and b/Examples/DC_motor_speed_control/DC_motor_speed_control.png differ
diff --git a/Examples/DC_motor_speed_control/tinkercad_link.txt b/Examples/DC_motor_speed_control/tinkercad_link.txt
new file mode 100644 (file)
index 0000000..188b34e
--- /dev/null
@@ -0,0 +1 @@
+https://www.tinkercad.com/things/3tiT8HWMh1X-dcmotorspeedcontrol