-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patht6a.ino
48 lines (38 loc) · 808 Bytes
/
t6a.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
#define M1 3
#define M2 5
#define MINSPEED 100
#define GREEN 11
#define RED 12
float time;
void setup() {
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(RED, OUTPUT);
}
void loop() {
// 5 seconds / (255-minspeed) <- number of intervals
time = (5) / (255 - MINSPEED);
// clockwise 5 seconds
digitalWrite(GREEN, HIGH);
digitalWrite(RED, LOW);
for (int i = MINSPEED; i <= 255; i++) {
analogWrite(M1, i);
analogWrite(M2, 0);
delay(time);
}
// pause 2 seconds
digitalWrite(GREEN, LOW);
digitalWrite(RED, LOW);
analogWrite(M1, 0);
analogWrite(M2, 0);
delay(2000);
// counter clockwise 5 seconds
digitalWrite(GREEN, LOW);
digitalWrite(RED, HIGH);
for (int i = MINSPEED; i <= 255; i++) {
analogWrite(M1, 0);
analogWrite(M2, i);
delay(time);
}
}