-
Notifications
You must be signed in to change notification settings - Fork 0
/
C4_786.ino
101 lines (75 loc) · 1.29 KB
/
C4_786.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
cipher 4:
quad intensity 786
// Motor A connections
int enA = 5;
int in1 = 6;
int in2 = 7;
// Motor B connections
int enB = 10;
int in3 = 8;
int in4 = 9;
void setup() {
// Set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
// Turn off motors - Initial state
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
analogWrite(enA, 255);
analogWrite(enB, 255);
}
void loop() {
//01 11 10 00 01 10
turn_on();
send_01();
delay(1000);
turn_on();
send_11();
delay(1000);
turn_on();
send_10();
delay(1000);
turn_on();
send_00();
delay(1000);
turn_on();
send_01();
delay(1000);
turn_on();
send_10();
delay(1000);
}
void send_00(){
analogWrite(enA, 0);
analogWrite(enB, 0);
}
void send_01(){
analogWrite(enA, 70);
analogWrite(enB, 70);
}
void send_10(){
analogWrite(enA, 160);
analogWrite(enB, 160);
}
void send_11(){
analogWrite(enA, 250);
analogWrite(enB, 250);
}
void turn_on() {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
void turn_off() {
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}