From: Vladimir Garistov Date: Fri, 26 Nov 2021 09:17:17 +0000 (+0200) Subject: Added a simple DC motor example X-Git-Url: https://kolegite.com/gitweb/?a=commitdiff_plain;h=f270a028f3b1b68f398af06c0912505f6174e17b;p=vmks.git Added a simple DC motor example --- 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 index 0000000..086bee0 --- /dev/null +++ b/Examples/DC_motor_speed_control/DC_motor_speed_control.ino @@ -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 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 index 0000000..188b34e --- /dev/null +++ b/Examples/DC_motor_speed_control/tinkercad_link.txt @@ -0,0 +1 @@ +https://www.tinkercad.com/things/3tiT8HWMh1X-dcmotorspeedcontrol