├── ArduinoLight └── ArduinoLight.pde └── README /ArduinoLight/ArduinoLight.pde: -------------------------------------------------------------------------------- 1 | const int cnlPins[3] = {10, 11, 9}; 2 | 3 | void setup() { 4 | Serial.begin(9600); 5 | for (int i=0; i<3; i++) { 6 | pinMode(cnlPins[i], OUTPUT); // init pin for channel 7 | } 8 | } 9 | 10 | void loop() { 11 | byte data; 12 | 13 | // Wait until we have the start byte) 14 | while (Serial.available() < 1) { } 15 | 16 | // Check we're starting at the right place 17 | if (Serial.read() == 0x55) { 18 | // Wait until we have the start byte) 19 | while (Serial.available() < 1) { } 20 | if (Serial.read() == 0xAA) { 21 | // Ensure that we have 3 data bytes 22 | while (Serial.available() < 3) { } 23 | 24 | for (int i=0; i<3; i++) { 25 | data = Serial.read(); 26 | analogWrite(cnlPins[i], data); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeincontext/ArduinoLight/4939a13835701b40d3d5302b79933b5a8c38de2d/README --------------------------------------------------------------------------------