From 4458a9c269a5ee097b79b24ceac0ed66998dc4cd Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 18 Oct 2022 14:34:43 +0800 Subject: [PATCH] add dc example --- README.md | 0 example/DC_Motor/DC_Motor.ino | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 README.md create mode 100644 example/DC_Motor/DC_Motor.ino diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/example/DC_Motor/DC_Motor.ino b/example/DC_Motor/DC_Motor.ino new file mode 100644 index 0000000..4ca95fc --- /dev/null +++ b/example/DC_Motor/DC_Motor.ino @@ -0,0 +1,26 @@ +#define DIR1 4 // define direction 4 port +#define PWM1 5 // define pwm1 5 port +#define DIR2 7 // define direction 7 port +#define PWM2 6 // define pwm1 6 port + +void setup() { + pinMode(DIR1, OUTPUT); + pinMode(PWM1, OUTPUT); + pinMode(DIR2, OUTPUT); + pinMode(PWM2, OUTPUT); +} + +void loop() { + // forward speed 255 + digitalWrite(DIR1, HIGH); + digitalWrite(PWM1, 255); + digitalWrite(DIR2, HIGH); + digitalWrite(PWM2, 255); + delay(2000); + // reversal speed 255 + digitalWrite(DIR1, LOW); + digitalWrite(PWM1, 255); + digitalWrite(DIR2, LOW); + digitalWrite(PWM2, 255); + delay(2000); +}