Only B works?

This commit is contained in:
Paul Warren 2023-11-21 19:35:50 +11:00
parent d8f88b7636
commit 0996c9bca5

View file

@ -17,6 +17,11 @@ int mapLEDIndex(int idx) {
}
}
int r = 255;
int g = 0;
int b = 200;
void setup() {
int idx;
@ -33,8 +38,8 @@ void setup() {
for (int i = 0; i< 8; i++) {
idx = mapLEDIndex(i);
rgbDriver.setLedBrightness(idx, 0x0f);
rgbDriver.setLedColour(idx, 0xff, 0x00, 0x99);
rgbDriver.setLedBrightness(idx, 0x1f);
rgbDriver.setLedColour(idx, r, g, b);
delay(500);
}
Serial.println("LEDS Lit!");
@ -42,7 +47,46 @@ void setup() {
void loop() {
int idx;
if (Serial.available()) {
char ch = Serial.read();
switch (ch) {
case 'r':
r += 10;
if (r > 255) {r = 255;}
case 'R':
r -= 10;
if (r < 0) {r=0;}
case 'g':
g += 10;
if (g > 255) {g = 255;}
case 'G':
g -= 10;
if (g < 0) {g=0;}
case 'b':
b += 10;
if (b > 255) {b = 255;}
case 'B':
b -= 10;
if (b < 0) {b=0;}
default:
break;
}
Serial.print("R: "); Serial.print(r);
Serial.print(" B: "); Serial.print(g);
Serial.print(" G: "); Serial.println(b);
for (int i = 0; i<8; i++) {
idx = mapLEDIndex(i);
rgbDriver.setLedBrightness(idx, 0x1f);
rgbDriver.setLedColour(idx, r, g, b);
}
}
}