-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinarytimer.ino
More file actions
73 lines (63 loc) · 1.27 KB
/
binarytimer.ino
File metadata and controls
73 lines (63 loc) · 1.27 KB
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
// I only can go up to 63 since the kit
// I got only had 6 LEDs
const int LED1 = 1; // LED connected to
const int LED2 = 2; // LED connected to
const int LED3 = 3; // LED connected to
const int LED4 = 4; // LED connected to
const int LED5 = 5; // LED connected to
const int LED6 = 6; // LED connected to
int i;
int delaylength;
void setup()
{
// sets the digital
// pins as output
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
i=0;
delaylength=3000;
}
void loop()
{
i=i+1;
// When you reach 64*3 seconds, start flashing slowly
if (i>64) {
i=63;
delaylength=500;
}
if (i&32) {
digitalWrite(LED6, HIGH);
} else {
digitalWrite(LED6, LOW);
}
if (i&16) {
digitalWrite(LED5, HIGH);
} else {
digitalWrite(LED5, LOW);
}
if (i&8) {
digitalWrite(LED4, HIGH);
} else {
digitalWrite(LED4, LOW);
}
if (i&4) {
digitalWrite(LED3, HIGH);
} else {
digitalWrite(LED3, LOW);
}
if (i&2) {
digitalWrite(LED2, HIGH);
} else {
digitalWrite(LED2, LOW);
}
if (i&1) {
digitalWrite(LED1, HIGH);
} else {
digitalWrite(LED1, LOW);
}
delay(delaylength); // waits for 3 seconds
}