-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
dot227-big-dc-motor-driver.ino
55 lines (36 loc) · 1.48 KB
/
dot227-big-dc-motor-driver.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// big motor driver check
// By Jeremy Ellis
// MIT license
// for now reference at https://github.com/hpssjellis/particle.io-photon-high-school-robotics/tree/master/a11-dc-motor-drivers
// although pin names wrong
// You are suppossed to get it working using the web-app
// Draw your circuit diagram first
// This program will just tell you if the connections are working
// See https://www.pololu.com/product/1451 for assistance
// On motor driver board LED goes red for one direction and green for the other
#include <Arduino.h> // Only needed by https://platformio.org/
void setup() {
pinMode(D3, OUTPUT); // digital 0 to 1
pinMode(D4, OUTPUT); // PWM 0 to 255
pinMode(D5, OUTPUT); // digital 0 to 1
pinMode(LEDB, OUTPUT); // onboard LED on if LOW
}
void loop() {
digitalWrite(LEDB, 0); // D7 on
// both off = glide, both on = brake (if motor can do that)
digitalWrite(D5, 1); // set one direction
digitalWrite(D3, 0); // set one direction
analogWrite(D4, 50); // go medium
delay(3000);
analogWrite(D4, 0); // stop
delay(3000);
digitalWrite(D5, 0); // set other direction
digitalWrite(D3, 1); // set one direction
analogWrite(D4, 50); // go medium
delay(1000);
analogWrite(D4, 255); // go full speed
delay(1000);
analogWrite(D4, 0); // stop
digitalWrite(LEDB, 1); // D7 off
delay(9000); // wait 9 seconds
}