/*
colors are 1,2,4, 1 is Red, 2 is Green, 4 is Blue
light are 1,2,4,8, so that light 7 is lights 1,2,4
*/
const uint8_t ledPins[] = {17, 14, 26,
25, 33, 32,
18, 5, 23,
22, 21, 4
};
String a = "";
String oscCommand = "";
// Split OSC Command
String* splitOSCCommand(String command) {
static String components[4];
int index = 0;
int start = 0;
int end = command.indexOf('/');
while (end != -1 && index < 3) {
components[index++] = command.substring(start, end);
start = end + 1;
end = command.indexOf('/', start);
}
components[index] = command.substring(start); // Last component
return components;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
for (byte i = 0; i <= 11; i++) {
pinMode(ledPins[i], OUTPUT);
digitalWrite(ledPins[i], LOW);
}
Serial.println("Setup done.");
}
void loop() {
// put your main code here, to run repeatedly:
while (Serial.available()) {
a = Serial.readString();// read the incoming data as string
Serial.println(a);
String* components = splitOSCCommand(a);
for (int i = 0; i < 3; i++) {
Serial.println(components[i]);
}
if (components[0] == "ledcounter"){
Serial.println("Going active");
}
}
delay(10); // this speeds up the simulation
/* for (uint8_t i = 0; i <= 11; i++) {
Serial.println(i);
digitalWrite(ledPins[i], HIGH);
delay(200);
digitalWrite(ledPins[i], LOW);
//delay(500);
} */
}