#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SLAVE_ADDRESS 0x12 #define PIN_LED 13 #define PIN_STRIP 6 // Parameter 1 = number of pixels in strip // Parameter 2 = pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, PIN, NEO_GRB + NEO_KHZ800); void setup() { Wire.begin(SLAVE_ADDRESS); Wire.onReceive(receiveData); pinMode(PIN_LED, OUTPUT); digitalWrite(PIN_LED, LOW); strip.begin();// initialize strip strip.show(); // Update all LEDs (= turn OFF, since none of them have been set yet!) c = strip.Color(255, 0, 0); // define the variable c as RED (R,G,B) strip.setPixelColor(2, c); // set LED 10 to the color in variable c (red) strip.show(); // Update all LEDs (= make LED 10 red) } void loop() { delay(10000); } void receiveData(int byteCount) { while(Wire.available()) { if (1 == Wire.read()) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); } } }