Skip to content
Snippets Groups Projects
Verified Commit 7cf3200e authored by Andreas Horn's avatar Andreas Horn
Browse files

adds example and test program for mixing colors via serial communication

parent 370a6c67
No related branches found
No related tags found
No related merge requests found
#include "rgbw-strip-12bit.h"
// one block has 6 LEDs
#define NUM_STRIP_BLOCKS 1
#define DIN 5
#define CLK 6
#define LAT 7
#define BLK 8 // set to -1 to if not used (can be pulled to GND manually)
RgbwStrip12bit strip = RgbwStrip12bit(NUM_STRIP_BLOCKS, CLK, DIN, LAT, BLK);
void setup() {
Serial.begin(115200);
Serial.println("12bit RGBW serial color mixer [up, down]: [r,e] red, [g,f] green, [b,v] blue, [w,q] white. Shift for factor 10.");
strip.begin();
}
int r = 20;
int g = 20;
int b = 20;
int w = 20;
void loop() {
if (Serial.available()) {
char input = Serial.read();
switch (input) {
case 'r': r++; break;
case 'e': r--; break;
case 'g': g++; break;
case 'f': g--; break;
case 'b': b++; break;
case 'v': b--; break;
case 'w': w++; break;
case 'q': w--; break;
case 'R': r += 10; break;
case 'E': r -= 10; break;
case 'G': g += 10; break;
case 'F': g -= 10; break;
case 'B': b += 10; break;
case 'V': b -= 10; break;
case 'W': w += 10; break;
case 'Q': w -= 10; break;
}
if (r >= 4096) r = 0;
if (r <= -1) r = 4095;
if (g >= 4096) g = 0;
if (g <= -1) g = 4095;
if (b >= 4096) b = 0;
if (b <= -1) b = 4095;
if (w >= 4096) w = 0;
if (w <= -1) w = 4095;
char out[34];
sprintf(out, "r: %4d, g: %4d, b: %4d, w: %4d", r, g, b, w);
Serial.println(out);
}
for (int i = 0; i < 6; i++) {
strip.setLED(i, r, g, b, w);
}
strip.write();
delay(10);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment