#include <Plaquette.h>
String command; //variable that is a string
DigitalOut greenLed(2);
DigitalOut whiteLed(3);
DigitalOut blueLed(4);
void begin() {
// put your setup code here, to run once:
Serial.println("Type command: white, blue, green, all, off");
}
void step() {
if (Serial.available()) {
command = Serial.readStringUntil('\n'); //attention: not forward slash!
command.trim(); // eliminate blank spaces around the chars
Serial.println(command);
if (command.equals("white")) {
whiteLed.on();
blueLed.off();
greenLed.off();
}
else if (command.equals("blue")) {
whiteLed.off();
blueLed.on();
greenLed.off();
}
else if (command.equals("green")) {
whiteLed.off();
blueLed.off();
greenLed.on();
}
else if (command.equals("all")) {
whiteLed.on();
blueLed.on();
greenLed.on();
}
else if (command.equals("off")) {
whiteLed.off();
blueLed.off();
greenLed.off();
}
else {
Serial.println (" is not a valid command");
}
}
}