D4에 해당되는 LED를 on, off힙니다.
#include <ESP8266WiFi.h> #define LED4 2 const char* ssid = "IOT999"; const char* password = "kbs48752"; IPAddress local_IP(192, 168, 0, 17); IPAddress gateway(192, 168, 0, 1); IPAddress subnet(255, 255, 255, 0); WiFiServer server(80); void setup() { Serial.begin(115200); pinMode(LED4, OUTPUT); WiFi.config(local_IP, gateway, subnet); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.println("."); } server.begin(); Serial.print(WiFi.localIP()); } void loop() { WiFiClient client = server.available(); if (!client) { return; } Serial.print("New client: "); Serial.println(client.remoteIP()); while(!client.available()){ delay(1); } String request = client.readStringUntil('\r'); Serial.println(request); if (request.indexOf("on4") != -1) { digitalWrite(LED4, HIGH); } if (request.indexOf("off4") != -1){ digitalWrite(LED4, LOW); } Serial.println(client.remoteIP()); client.flush(); client.stop(); } |
'IOT(Arduino+Inventor)' 카테고리의 다른 글
ESP8266_AM2320_LED (0) | 2023.03.14 |
---|---|
esp8266_LED_On_OFF (1) | 2023.03.13 |
온도센서_AM2320_ECP8266_LED_E (0) | 2023.03.07 |
온도센서_AM2320_ESP8266_Inventor_D (0) | 2023.03.06 |
온도센서_AM2320_ESP8266_CSS_C (0) | 2023.03.06 |