Skip to content
Snippets Groups Projects
Commit f4fc39e9 authored by Akseli Uunila's avatar Akseli Uunila
Browse files

Add checking of commands and acting on them

parent 0067a458
No related branches found
No related tags found
No related merge requests found
......@@ -30,11 +30,11 @@ void loop() {
// Blink the NeoPixel
pixels.clear(); // Set all pixel colors to 'off'
// We only have one pixel, therefore the first argument (index) is 0
pixels.setPixelColor(0, pixels.Color(25, 25, 205)); // Nice blue color
pixels.setPixelColor(0, pixels.Color(25, 25, 180)); // Nice blue color
pixels.show(); // Send the updated pixel colors to the hardware.
delay(DELAYVAL); // wait between
pixels.clear();
pixels.setPixelColor(0, pixels.Color(180, 180, 25)); // Nice yellow color
pixels.setPixelColor(0, pixels.Color(150, 150, 25)); // Nice yellow color
pixels.show();
} else {
......@@ -49,10 +49,20 @@ void loop() {
delay(DELAYVAL);
String test_str; // Initialize the variable
if (Serial.available() > 0) { // If there is incoming bytes in the serial:
test_str = Serial.readString(); // This reads the serial buffer to a String
String input_str = Serial.readString(); // This reads the serial buffer to a String
input_str.trim(); // remove any \r \n whitespace at the end of the String
Serial.print("You wrote: ");
Serial.println(test_str); // Send it back to see if this works
Serial.println(input_str); // Send it back to see if this works
// Set the boolean accordingly
if (input_str == "blink") {
Serial.println("Ok, blinking");
blinking = true;
} else if (input_str == "stop") {
Serial.println("Ok, stopping");
blinking = false;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment