-
Notifications
You must be signed in to change notification settings - Fork 0
/
musique.ino
146 lines (138 loc) · 2.71 KB
/
musique.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
void readMSGEQ7() // Function to read 7 band equalizers
{
int band;
digitalWrite(PIN_RES_MSGEQ7, HIGH);
digitalWrite(PIN_RES_MSGEQ7, LOW);
for (band = 0; band < 7; band++)
{
digitalWrite(PIN_STROBE_MSGEQ7, LOW); // strobe pin on the shield - kicks the IC up to the next band
delayMicroseconds(300); //
left[band] = analogRead(PIN_MSG_MSGEQ7); // store left band reading
digitalWrite(PIN_STROBE_MSGEQ7, HIGH);
}
//Décaler les LED pour enlever celle de gauche
for (band = 0; band < 6; band++)
{
left[band] = left[band + 1];
}
left[3] = (left[3] + left[4]) / 2;
left[4] = (left[5] + left[6]) / 2;
for (band = 0; band < 7; band++)
{
left[band] = left[band];
}
}
void test_musique_volume()
{
float moyenne = 0;
for (int i = 0; i < size_of_cube; i++)
{
moyenne = moyenne + left[i];
}
moyenne = moyenne / size_of_cube;
Serial.println(moyenne);
}
void anim_musique1()
{
int x, y;
float moyenne = 0;
LED_All_Clear();
for (int i = 0; i < size_of_cube; i++)
{
moyenne = moyenne + left[i];
}
moyenne = moyenne / size_of_cube;
if (moyenne > 90)
{
for (x = 0; x < size_of_cube; x++)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(x, y, 0, 0, 0, 255);
}
}
}
if (moyenne > 140)
{
for (x = 0; x < size_of_cube; x++)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(x, y, 1, 80, 0, 180);
}
}
}
if (moyenne > 160)
{
for (x = 0; x < size_of_cube; x++)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(x, y, 2, 120, 0, 120);
}
}
}
if (moyenne > 180)
{
for (x = 0; x < size_of_cube; x++)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(x, y, 3, 180, 0, 80);
}
}
}
if (moyenne > 200)
{
for (x = 0; x < size_of_cube; x++)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(x, y, 4, 255, 0, 0);
}
}
}
}
void anim_musique2()
{
int y;
LED_All_Clear();
for (int freq = 0; freq < size_of_cube; freq++)
{
if (left[freq] > 150)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(freq, y, 0, 0, 255, 0);
}
}
if (left[freq] > 300)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(freq, y, 1, 255, 125, 0);
}
}
if (left[freq] > 550)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(freq, y, 2, 255, 0, 0);
}
}
if (left[freq] > 700)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(freq, y, 3, 255, 127, 0);
}
}
if (left[freq] > 900)
{
for (y = 0; y < size_of_cube; y++)
{
LED_Set(freq, y, 4, 255, 0, 0);
}
}
}
}