-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhex_nanoTest.ino
43 lines (35 loc) · 1008 Bytes
/
hex_nanoTest.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <FastLED.h>
#include <Wire.h>
#define NUM_LEDS 6
#define LED_PIN 3
CRGB leds[NUM_LEDS];
uint8_t paletteIndex = 0;
byte messageArray[6];
void receiveEvent(int howMany) {
Serial.println(howMany);
for(int i = 0; i < howMany; i++){
messageArray[i] = Wire.read();
Serial.print(messageArray[i]);
}
Serial.println();
}
void setup() {
// put your setup code here, to run once:
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
Wire.begin(8); /* join i2c bus with address 8 */
Wire.onReceive(receiveEvent); /* register receive event */
Serial.begin(9600); /* start serial for debug */
}
void loop() {
// put your main code here, to run repeatedly:
if (messageArray[3] == 2) {
fill_palette(leds, NUM_LEDS, paletteIndex, 1, RainbowColors_p, 255, LINEARBLEND);
EVERY_N_MILLISECONDS(50) {
paletteIndex++;
}
FastLED.show();
} else {
FastLED.clear();
FastLED.show();
}
}