Moderator: igrr
See this http://www.esp8266.com/viewtopic.php?f=29&t=2451
Maybe: http://www.esp8266.com/viewtopic.php?f=27&t=4080#p23577
But, you can really do a lot of neat stuff if you use SPIFFS to store javascript and HTML5 code for the client then talk over the connection if websockets. My project here.
Ray
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
const int back=D8;
const int go=D7;
const int left=D6;
const int right=D5;
const char *ssid = "MyESPAP";
const char *password = "MyPassword";
WiFiServer server(80);
void setup()
{
Serial.begin(115200);
Serial.println("Test4");
pinMode(go,OUTPUT);
pinMode(back,OUTPUT);
pinMode(right,OUTPUT);
pinMode(left,OUTPUT);
digitalWrite(go,HIGH);
digitalWrite(back,LOW);
digitalWrite(left,LOW);
digitalWrite(right,HIGH);
//WiFi.disconnect();
delay(100);
WiFi.mode(WIFI_AP);
Serial.println("Configuring Access Point ...");
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print(myIP);
server.begin();
}
WiFiClient client;
char c;
int count=0;
void loop()
{
Serial.println("I am in loop...");
if (!client.connected()) {
Serial.println("Waiting client...");
client = server.available();
}
while(client.connected()) {
if (client.available() > 0) {
c = (char)client.read();
Serial.println(c);
if(c=='F')
{
digitalWrite(back,LOW);
digitalWrite(go,LOW);
}
if(c=='B')
{
digitalWrite(go,HIGH);
digitalWrite(back,HIGH);
}
if(c=='S')
{
digitalWrite(back,LOW);
digitalWrite(go,HIGH);
}
if(c=='R')
{
digitalWrite(left,LOW);
digitalWrite(right,LOW);
}
if(c=='L')
{
digitalWrite(right,HIGH);
digitalWrite(left,HIGH);
}
if(c=='M')
{
digitalWrite(right,HIGH);
digitalWrite(left,LOW);
}
}
while(!(client.available()>0))
{
delay(50);
count++;
if(count>60)
{
client.stop();
return;
}
}
count=0;
}
client.stop();
digitalWrite(go,HIGH);
digitalWrite(back,LOW);
digitalWrite(left,LOW);
digitalWrite(right,HIGH);
}
You see that "Test4" there in the setup. I don't see it when I reset or switch device on.
Some part of the code may seem really beginner level . You might guess that I am working on a RCCar project. But it works pretty well except that problem I mentioned.