-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBluetoothSetColor.ino
More file actions
46 lines (35 loc) · 884 Bytes
/
Copy pathBluetoothSetColor.ino
File metadata and controls
46 lines (35 loc) · 884 Bytes
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
44
45
46
#include <SoftwareSerial.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
#define NUM_LEDS 8
#define BRIGHTNESS 255
Adafruit_NeoPixel ring = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
SoftwareSerial bluetooth(2,3);
void setup() {
ring.begin();
ring.setBrightness(BRIGHTNESS);
ring.show();
bluetooth.begin(9600);
}
int r = 0, g = 0, b = 0;
void loop() {
if(bluetooth.available() > 2){
ring.begin();
r = bluetooth.read();
g = bluetooth.read();
b = bluetooth.read();
bluetooth.flush();
ring.setPixelColor(0, ring.Color(r,g,b));
ring.show();
delay(300);
ring.setPixelColor(4, ring.Color(r,g,b));
ring.show();
delay(300);
ring.setPixelColor(8, ring.Color(r,g,b));
ring.show();
delay(300);
}
}