-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForwardBackwardTest.ino
48 lines (36 loc) · 1.67 KB
/
ForwardBackwardTest.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
void setup() {
//Setup code, to run once:
//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin
//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel B pin
pinMode(8, OUTPUT); //Initiates Brake Channel B pin
}
void loop() {
//Main code, to run repeatedly:
//Motor A forward @ full speed
digitalWrite(12, HIGH); //Establishes forward direction of Channel B
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
//Motor B forward @ full speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at full speed
delay(1000); //Forward motion
digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(8, HIGH); //Engage the Brake for Channel B
delay(1000); //Stationary
//Motor A backward @ full speed
digitalWrite(12, LOW); //Establishes backward direction of Channel B
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
//Motor B backward @ full speed
digitalWrite(13, LOW); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at full speed
delay(1000); //Backwards motion
digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(8, HIGH); //Engage the Brake for Channel B
delay(1000); //Stationary
}