-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDList.pde
67 lines (60 loc) · 1.34 KB
/
LEDList.pde
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
int col = 12;
int row = 14;
int[][] led = new int[col][row];//12cols x 14rows
int ledLoc = 0;
int[] ledLength = {13, 12, 11, 7, 7, 8, 11, 8, 9, 9, 7};
int w = 400/14;
int ledX = -1;
int ledY;
void setup() {
size(400, 400);
frameRate(6);
//LED Matrix Initiate
for (int y=0; y<led.length; y++) {
for (int x=0; x<led[y].length; x++) {
led[y][x] = -1;
}
}
//Set 1st LED position of every LEDstrip
for (int y=0; y<led.length-1; y++) {
if (y==0) {
led[y][0]=0;
} else {
led[y][0]=led[y-1][0]+ledLength[y-1];
}
//print((y+1)+":"+led[y][0]+",");
}
//Initiate every posible LEDs
for (int y=0; y<led.length-1; y++) {
for (int x=0; x<ledLength[ledLoc]; x++) {
led[y][x+1] = led[y][x]+1;
//print(led[y][x]+",");
}
ledLoc++;
//println();
}
}
void draw() {
//LEDBoard Visualization
background(255);
for (int y=0; y<w; y++) {
for (int x=0; x<w; x++) {
stroke(0);
noFill();
rect(x*w, y*w, w, w);
stroke(0);
noFill();
ellipse(x*w+w/2, y*w+w/2, w/2, w/2);
}
}
//TurnOn exist LEDs
for (ledY=0; ledY<11; ledY++) {
if (ledX<ledLength[ledY]) {
fill(255, 0, 0);
ellipse(ledX*w+w/2, ledY*w+w/2, w/2, w/2);
}
}
if (ledX < 14) {
ledX++;
}
}