void modeCommand(YunClient client) { int pin; // Read pin number pin = client.parseInt(); // If the next character is not a '/' we have a malformed URL if (client.read() != '/') { client.println(F("error")); return; } String mode = client.readStringUntil('\r'); if (mode == "input") { pinMode(pin, INPUT); // Send feedback to client client.print(F("Pin D")); client.print(pin); client.print(F(" configured as INPUT!")); return; } if (mode == "output") { pinMode(pin, OUTPUT); // Send feedback to client client.print(F("Pin D")); client.print(pin); client.print(F(" configured as OUTPUT!")); return; } client.print(F("error: invalid mode ")); client.print(mode); }
void process(YunClient client) { String command = client.readStringUntil('/'); // Check if the url contains the word "servo" if (command == "servo") { servoCommand(client); } }