Skip to content

Commit

Permalink
add dc example
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhou-lei committed Oct 18, 2022
1 parent f6d3abb commit 4458a9c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Empty file added README.md
Empty file.
26 changes: 26 additions & 0 deletions example/DC_Motor/DC_Motor.ino
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 4458a9c

Please sign in to comment.