-
Notifications
You must be signed in to change notification settings - Fork 2
/
sketch.ino
48 lines (41 loc) · 1.29 KB
/
sketch.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
44
45
46
47
48
#include <Adafruit_Arcada.h>
Adafruit_Arcada arcada;
String inData;
void timercallback(void) {
Serial.println(arcada.readLightSensor());
}
void setup() {
Serial.begin(9600);
arcada.arcadaBegin();
}
void loop() {
while (Serial.available() > 0)
{
char recieved = Serial.read();
inData += recieved;
// Process message when new line character is recieved
if (recieved == '\n')
{
//Serial.print("Arduino Received: ");
//Serial.println(inData);
switch (inData[0]) {
case 'f':
arcada.timerCallback(inData.substring(1).toFloat(), timercallback);
break;
case '1': //LED on
for(int32_t i=0; i< arcada.pixels.numPixels(); i++) {
arcada.pixels.setPixelColor(i, arcada.pixels.Color(25, 25, 100));
}
arcada.pixels.show();
break;
case '0': //LED off
for(int32_t i=0; i< arcada.pixels.numPixels(); i++) {
arcada.pixels.setPixelColor(i, arcada.pixels.Color(0, 0, 0));
}
arcada.pixels.show();
break;
}
inData = ""; // Clear recieved buffer
}
}
}