Created
December 19, 2020 13:04
-
-
Save makerstorage/bb18e422b4976dcdddb9d605b74829fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <ESP8266WiFi.h> | |
| const char* ssid = "wifi adınız"; | |
| const char* password = "şifreniz"; | |
| const int stepPin = 13 ; | |
| const int dirPin = 12; | |
| WiFiServer server(80); | |
| void setup() { | |
| Serial.begin(115200); | |
| delay(10); | |
| pinMode(stepPin, OUTPUT); | |
| pinMode(dirPin, OUTPUT); | |
| Serial.println(); | |
| Serial.println(); | |
| Serial.print("Baglaniyor"); | |
| Serial.println(ssid); | |
| WiFi.begin(ssid, password); | |
| while (WiFi.status() != WL_CONNECTED) { | |
| delay(500); | |
| Serial.print("."); | |
| } | |
| Serial.println(""); | |
| Serial.println("WiFi bagli"); | |
| server.begin(); | |
| Serial.println("Server Baslatildi"); | |
| Serial.print("Baglanmak icin bu URL'yi kullanin: "); | |
| Serial.print("http://"); | |
| Serial.print(WiFi.localIP()); | |
| Serial.println("/"); | |
| } | |
| void loop() { | |
| WiFiClient client = server.available(); | |
| if (!client) { | |
| return; | |
| } | |
| Serial.println("Yeni kisi "); | |
| while(!client.available()){ | |
| delay(1); | |
| } | |
| String request = client.readStringUntil('\r'); | |
| Serial.println(request); | |
| client.flush(); | |
| int value = LOW; | |
| if (request.indexOf("/MOTOR-ILERI") != -1) { | |
| digitalWrite(dirPin, HIGH); | |
| for(int i = 0 ; i<100;i++){ | |
| digitalWrite(stepPin,HIGH); | |
| delayMicroseconds(1500); | |
| digitalWrite(stepPin,LOW); | |
| delayMicroseconds(1500); | |
| } | |
| value = HIGH; | |
| } | |
| if (request.indexOf("/MOTOR-GERI") != -1) { | |
| digitalWrite(dirPin, LOW); | |
| for(int i = 0 ; i<100;i++){ | |
| digitalWrite(stepPin,HIGH); | |
| delayMicroseconds(1500); | |
| digitalWrite(stepPin,LOW); | |
| delayMicroseconds(1500); | |
| } | |
| value = LOW; | |
| } | |
| client.println("HTTP/1.1 200 OK"); | |
| client.println("Content-Type: text/html"); | |
| client.println(""); | |
| client.println("<!DOCTYPE HTML>"); | |
| client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); | |
| client.println("<link rel=\"icon\" href=\"data:,\">"); | |
| client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}"); | |
| client.println(".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;"); | |
| client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}"); | |
| client.println(".button2 {background-color: #77878A;}</style></head>"); | |
| client.println("<body><h1>ESP8266 MOTOR KONROL</h1>"); | |
| client.println("<html>"); | |
| client.println(""); | |
| client.println("<a href=\"/MOTOR-ILERI\"><button class=\"button\">Ileri</button></a>"); | |
| client.println("<a href=\"/MOTOR-GERI\"><button class=\"button button2\">Geri</button></a>"); | |
| client.println("</html>"); | |
| client.println("<br>"); | |
| client.println("<br>"); | |
| delay(1); | |
| client.print("<h3>Motor :</h3>"); | |
| if(value == HIGH) { | |
| client.print("<h3>Ileriye döndü</h3>"); | |
| } else { | |
| client.print("<h3>Geriye döndü</h3>"); | |
| } | |
| Serial.println("Client disonnected"); | |
| Serial.println(""); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment