#include #include #define PIN 5 #define NUMPIXELS 40 Adafruit_NeoPixel Pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); int LED_Ausgabe[8][4] = //Belegung Feld - LED { {0, 1, 6, 7}, //A3 {1, 2, 7, 8}, //A4 {2, 3, 8, 9}, //A5 {4, 5, 12, 13}, //B1 {5, 6, 13, 14}, //B2 {6, 7, 14, 15}, //B3 {7, 8, 15, 16}, //B4 {8, 9, 16, 17} //B5; }; // Init ShiftIn instance with a single chip ShiftIn<1> shift; int Schalter_ID = 0; int laenge_Input = 0; void setup() { Serial.begin(9600); Pixels.begin(); Pixels.show(); // declare pins: pLoadPin, clockEnablePin, dataPin, clockPin shift.begin(8, 9, 11, 12); } void loop() { if (shift.update()) { // read in all values. returns true if any button has changed laenge_Input = shift.getDataWidth(); Pixels.clear(); for (Schalter_ID = 0; Schalter_ID < laenge_Input; Schalter_ID++) { if (shift.state(Schalter_ID) == 1) { LED_set(Schalter_ID, 0, 20, 0); } Pixels.show(); } } } void LED_set(uint8_t i, uint8_t r, uint8_t g, uint8_t b) { int j; for (j = 0; j < 4; j++) { Pixels.setPixelColor(LED_Ausgabe[i][j], r, g, b); } }