rastable/arduino/stripok/stripok.ino

32 lines
538 B
Arduino
Raw Normal View History

2018-11-26 00:49:19 +01:00
#include "FastLED.h"
#include <Wire.h>
#define NUM_LEDS 6
#define DATA_PIN 6
#define SLAVE_ADDRESS 0x12
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
Wire.begin(SLAVE_ADDRESS);
Wire.onReceive(receiveData);
}
void loop() {
delay(500);
}
void receiveData(int byteCount) {
while(Wire.available()) {
if (1 == Wire.read()) {
leds[0] = CRGB::Red;
FastLED.show();
} else {
leds[0] = CRGB::Blue;
FastLED.show();
}
}
}