2024-08-28 22:48:06 +02:00
|
|
|
|
|
|
|
#define RED_LED 6
|
|
|
|
#define GREEN_LED 9
|
|
|
|
#define BLUE_LED 5
|
|
|
|
|
|
|
|
int brightness = 255;
|
|
|
|
int rb = 0;
|
|
|
|
int gb = 0;
|
|
|
|
int bb = 0;
|
|
|
|
int fadeSpeed = 10;
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
pinMode(RED_LED, OUTPUT);
|
|
|
|
pinMode(GREEN_LED, OUTPUT);
|
|
|
|
pinMode(BLUE_LED, OUTPUT);
|
|
|
|
|
2024-08-29 11:20:03 +02:00
|
|
|
Serial.begin(115200);
|
2024-08-28 22:48:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
char* result[3];
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
if(Serial.available() > 1)
|
|
|
|
{
|
|
|
|
char input[12];
|
|
|
|
byte size = Serial.readBytes(input, 11);
|
|
|
|
// Add the final 0 to end the C string
|
|
|
|
input[size] = 0;
|
|
|
|
|
|
|
|
// Read each command pair
|
|
|
|
char* command = strtok(input, ";");
|
|
|
|
int index = 0;
|
|
|
|
while (command != 0)
|
|
|
|
{
|
|
|
|
result[index] = command;
|
|
|
|
index += 1;
|
|
|
|
// Find the next command in input string
|
|
|
|
command = strtok(0, ";");
|
|
|
|
}
|
|
|
|
|
|
|
|
rb = atoi(result[0]);
|
|
|
|
gb = atoi(result[1]);
|
|
|
|
bb = atoi(result[2]);
|
|
|
|
|
|
|
|
analogWrite(RED_LED, rb);
|
|
|
|
analogWrite(GREEN_LED, gb);
|
|
|
|
analogWrite(BLUE_LED, bb);
|
|
|
|
|
2024-08-29 11:20:03 +02:00
|
|
|
//String out = (String)rb + ";" + (String)gb + ";" + (String)bb;
|
|
|
|
//Serial.println(out);
|
2024-08-28 22:48:06 +02:00
|
|
|
}
|
|
|
|
}
|