Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user