ok, muss auch sagen, dass dies meine erste Erfahrung mit einem Forum ist...
Aber ich werde mich bemühen.
wie man sehen kann, möchte ich mehrere selbstgebaute 7-Segment anzeigen steuern. Dafür nutze ich ws2812b Led's an einem Arduino Uno.
Btw, wie heißt eigentlich das, was bei mir jetzt z.B. zahl_sekunde heißt? Also wie bezeichnet an das fachsprachlich? -Dann könnte ich mir evtl. dazu auch selber noch was raussuchen...
#include <Adafruit_NeoPixel.h>
/* 4
-------
| | 5
3 | |
---6----
| | 0
2 | |
--------
1 */
#define NUMPIXELS 7
Adafruit_NeoPixel Zahl_sekunde(NUMPIXELS, 6, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Zahl_minute(NUMPIXELS, 7, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Zahl_stunde(NUMPIXELS, 8, NEO_GRB + NEO_KHZ800);
void setup() {
pixel.begin();
}
void loop() {
for (byte i = 0; i <= 9; i++) {
zahlAnzeigen(Zahl_sekunde, i, 0, 0, 255);
delay(1000);}
//zahlAnzeigen(Zahl_sekunde, 5, 0, 255,0);
}
void zahlAnzeigen(String pixel, byte zahl, byte r, byte g, byte b) {
pixel.clear();
switch (zahl) {
case 0: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(1, r, g, b);
pixel.setPixelColor(2, r, g, b);
pixel.setPixelColor(3, r, g, b);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(6, 0, 0, 0);
break;
case 1: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(1, 0, 0, 0);
pixel.setPixelColor(2, 0, 0, 0);
pixel.setPixelColor(3, 0, 0, 0);
pixel.setPixelColor(4, 0, 0, 0);
pixel.setPixelColor(6, 0, 0, 0);
break;
case 2: pixel.setPixelColor(1, r, g, b);
pixel.setPixelColor(2, r, g, b);
pixel.setPixelColor(3, 0, 0, 0);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(6, r, g, b);
break;
case 3: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(1, r, g, b);
pixel.setPixelColor(2, 0, 0, 0);
pixel.setPixelColor(3, 0, 0, 0);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(6, r, g, b);
break;
case 4: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(1, 0, 0, 0);
pixel.setPixelColor(2, 0, 0, 0);
pixel.setPixelColor(3, r, g, b);
pixel.setPixelColor(4, 0, 0, 0);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(6, r, g, b);
break;
case 5: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(2, 0, 0, 0);
pixel.setPixelColor(1, r, g, b);
pixel.setPixelColor(3, r, g, b);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, 0, 0, 0);
pixel.setPixelColor(6, r, g, b);
break;
case 6: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(1, r, g, b);
pixel.setPixelColor(2, r, g, b);
pixel.setPixelColor(3, r, g, b);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, 0, 0, 0);
pixel.setPixelColor(6, r, g, b);
break;
case 7: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(1, 0, 0, 0);
pixel.setPixelColor(2, 0, 0, 0);
pixel.setPixelColor(3, 0, 0, 0);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(6, 0, 0, 0);
break;
case 8: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(1, r, g, b);
pixel.setPixelColor(2, r, g, b);
pixel.setPixelColor(3, r, g, b);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(6, r, g, b);
break;
case 9: pixel.setPixelColor(0, r, g, b);
pixel.setPixelColor(1, r, g, b);
pixel.setPixelColor(6, r, g, b);
pixel.setPixelColor(3, r, g, b);
pixel.setPixelColor(4, r, g, b);
pixel.setPixelColor(5, r, g, b);
pixel.setPixelColor(2, 0, 0, 0);
break;
}
pixel.show();
}