-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproject.ino
73 lines (67 loc) · 1.71 KB
/
project.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
#include <ArduinoRS485.h> // the ArduinoDMX library depends on ArduinoRS485
#include <ArduinoDMX.h>
const int universeSize = 101;
void setup() {
Serial.begin(9600);
while (!Serial);
// initialize the DMX library with the universe size
if (!DMX.begin(universeSize)) {
Serial.println("Failed to initialize DMX!");
while (1); // wait for ever
}
}
// leds are 0 - 7
void setLeftLight(int led, int red, int green, int blue) {
DMX.beginTransmission();
int offset = 1;
offset = offset + (led * 6);
// Red = 0-255
DMX.write(offset + 2, red);
// Green = 0-255
DMX.write(offset + 3, green);
// Blue = 0-255
DMX.write(offset + 4, blue);
// Brightness = 0-255
DMX.write(offset, 100);
// Strobe = 0-255
DMX.write(offset + 1, 0);
DMX.endTransmission();
}
void setRightLight(int led, int red, int green, int blue) {
DMX.beginTransmission();
int offset = 51;
offset = offset + (led * 6);
// Red = 0-255
DMX.write(offset + 2, red);
// Green = 0-255
DMX.write(offset + 3, green);
// Blue = 0-255
DMX.write(offset + 4, blue);
// Brightness = 0-255
DMX.write(offset, 100);
// Strobe = 0-255
DMX.write(offset + 1, 0);
DMX.endTransmission();
}
void loop() {
int light;
for(light = 0; light <= 7; light++) {
// Lights ON
setLeftLight(7 - light, 255, 255, 255);
setRightLight(light, 255, 255, 255);
delay(100);
// Lights OFF
setLeftLight(7 - light,0,0,0);
setRightLight(light,0,0,0);
}
for(light = 1; light <= 6; light++) {
// Lights ON
setLeftLight(light, 255, 255, 255);
setRightLight(7 - light, 255, 255, 255);
delay(100);
// Lights OFF
setLeftLight(light,0,0,0);
setRightLight(7 - light,0,0,0);
// red = (red + 10) % 255;
}
}