-
Notifications
You must be signed in to change notification settings - Fork 0
/
C2_fib.ino
98 lines (78 loc) · 1.33 KB
/
C2_fib.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
// cipher 2:
// Fibonacci
// 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() {
turn_off();
delay(1000);
turn_off();
delay(1000);
turn_on();
delay(1000);
turn_off();
delay(1000);
turn_on();
delay(1000);
turn_off();
delay(1000);
turn_on();
delay(1000);
turn_on();
delay(1000);
turn_off();
delay(1000);
turn_on();
delay(1000);
turn_on();
delay(1000);
turn_on();
delay(1000);
turn_off();
delay(1000);
turn_on();
delay(1000);
turn_on();
delay(1000);
turn_on();
delay(1000);
turn_on();
delay(1000);
turn_on();
delay(1000);
turn_off();
delay(1000);
}
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);
}