#include #include #include #define SSID "Kuriyama-DIY-G" #define PASS "kuriyama" #define LED_PIN 13 Servo myservo; int minUs = 500; int maxUs = 2400; WebServer server(80); void setup(){ Serial.begin(9600); myservo.setPeriodHertz(50); myservo.attach(23, minUs, maxUs); pinMode(LED_PIN, OUTPUT); connectWiFi(); server.on("/", handleRoot); server.on("/nothing", nothing); server.on("/charcol", charcol); server.on("/notcharcol", notcharcol); server.on("/plastic", plastic); server.on("/battery", battery); server.begin(); Serial.println("HTTP server started"); } void loop() { server.handleClient(); } void connectWiFi(){ WiFi.begin(SSID, PASS); Serial.println(); while(WiFi.status() != WL_CONNECTED){ delay(500); Serial.print("."); } Serial.println(); Serial.println("WiFi connected"); Serial.println(WiFi.localIP()); } void handleRoot(){ server.send(200, "text/plain", "Hello"); } void nothing(){ Serial.println("nothing"); myservo.write(0); server.send(200, "text/plain", "nothing"); } void charcol(){ Serial.println("charcol"); myservo.write(60); server.send(200, "text/plain", "charcol"); } void notcharcol(){ Serial.println("notcharcol"); myservo.write(120); server.send(200, "text/plain", "notcharcol"); } void plastic(){ Serial.println("plastic"); myservo.write(180); server.send(200, "text/plain", "plastic"); } void battery(){ Serial.println("battery"); digitalWrite(LED_PIN, HIGH); delay(500); digitalWrite(LED_PIN, LOW); delay(500); server.send(200, "text/plain", "battery"); }