-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmotorDriverCode.ino
More file actions
45 lines (44 loc) · 986 Bytes
/
motorDriverCode.ino
File metadata and controls
45 lines (44 loc) · 986 Bytes
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
int motor_A_1 = 11;
int motor_A_2 = 10;
int motor_B_1 = 9;
int motor_B_2 = 8;
void setup() {
pinMode(motor_A_1,OUTPUT);
pinMode(motor_A_2,OUTPUT);
pinMode(motor_B_1,OUTPUT);
pinMode(motor_B_2,OUTPUT);
}
void loop() {
forwardDerection();
delay(1000);
reverseDerection();
delay(1000);
leftDerection();
delay(1000);
rightDerection();
delay(1000);
}
void forwardDerection(){
digitalWrite(motor_A_1,HIGH);
digitalWrite(motor_A_2,LOW);
digitalWrite(motor_B_1,HIGH);
digitalWrite(motor_B_2,LOW);
}
void reverseDerection(){
digitalWrite(motor_A_1,LOW);
digitalWrite(motor_A_2,HIGH);
digitalWrite(motor_B_1,LOW);
digitalWrite(motor_B_2,HIGH);
}
void leftDerection(){
digitalWrite(motor_A_1,HIGH);
digitalWrite(motor_A_2,LOW);
digitalWrite(motor_B_1,LOW);
digitalWrite(motor_B_2,HIGH);
}
void rightDerection(){
digitalWrite(motor_A_1,LOW);
digitalWrite(motor_A_2,HIGH);
digitalWrite(motor_B_1,HIGH);
digitalWrite(motor_B_2,LOW);
}