forked from processing/processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLedCounter.pde
More file actions
39 lines (33 loc) · 775 Bytes
/
LedCounter.pde
File metadata and controls
39 lines (33 loc) · 775 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
import processing.io.*;
LED leds[];
// the Raspberry Pi has two build-in LEDs we can control
// led0 (green) and led1 (red)
void setup() {
String available[] = LED.list();
print("Available: ");
println(available);
// create an object for each LED and store it in an array
leds = new LED[available.length];
for (int i=0; i < available.length; i++) {
leds[i] = new LED(available[i]);
}
frameRate(1);
}
void draw() {
// make the LEDs count in binary
for (int i=0; i < leds.length; i++) {
if ((frameCount & (1 << i)) != 0) {
leds[i].brightness(1.0);
} else {
leds[i].brightness(0.0);
}
}
println(frameCount);
}
void keyPressed() {
// cleanup
for (int i=0; i < leds.length; i++) {
leds[i].close();
}
exit();
}