Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

flowchart of this code #include WiFiServer server ( 8 0 ) ; const char * ssdi = ; const char * password =

flowchart of this code
#include
WiFiServer server(80);
const char* ssdi ="";
const char* password ="";
int contconexion =0;
String estadosalida1= "off";
String estadosalida2= "off";
String estadosalida3= "off";
String estadosalida4= "off";
String estadosalida5= "off";
String estadosalida6= "off";
String estadosalida7= "off";
bool d1;
bool d2;
bool d3;
bool i1;
bool i2;
bool i3;
bool cl;
//Control velocidad motores
int pasos =1;
int temp_esp =5;
int temp_espgr =60;
int temp =10;
// Definicin de pines
#define INA113
#define INB114
#define INC112
#define IND127
#define INA226
#define INB225
#define INC233
#define IND232
#define INA315
#define INB32
#define INC34
#define IND316
#define INA417
#define SW15
#define SW218
#define SW319
#define SW421
#define SW522
#define SW623
void setup(){
Serial.begin(115200);
Serial.println("");
pinMode(INA1, OUTPUT);
pinMode(INB1, OUTPUT);
pinMode(INC1, OUTPUT);
pinMode(IND1, OUTPUT);
pinMode(INA2, OUTPUT);
pinMode(INB2, OUTPUT);
pinMode(INC2, OUTPUT);
pinMode(IND2, OUTPUT);
pinMode(INA3, OUTPUT);
pinMode(INB3, OUTPUT);
pinMode(INC3, OUTPUT);
pinMode(IND3, OUTPUT);
pinMode(INA4, OUTPUT);
pinMode(SW1, INPUT);
pinMode(SW2, INPUT);
pinMode(SW3, INPUT);
pinMode(SW4, INPUT);
pinMode(SW5, INPUT);
pinMode(SW6, INPUT);
delay(temp);
WiFi.begin(ssdi, password);
while(WiFi.status()!= WL_CONNECTED and contconexion<50){
++contconexion;
delay(1000);
Serial.println(".");
}
if (contconexion<50){
//ip fija
IPAddress ip(192,168,1,180);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
WiFi.config(ip, gateway, subnet);
Serial.println("");
Serial.println("WiFi conectado");
Serial.println(WiFi.localIP());
server.begin(); //iniciamos el servidor
}else{
Serial.println("");
Serial.println("Error de conexion");
}
}
void loop(){
// put your main code here, to run repeatedly:
Serial.begin(115200);
WiFiClient client = server.available(); //Escucha a los clientes entrantes
if(client){//si se conecta un nuevo cliente
Serial.println("New Client.");
String currentLine ="";
while (client.connected()){//loop mientras el cliente este conectado
if(client.available()){//si hay bytes para leer desde el cliente
char c = client.read(); //lee un byte
Serial.write(c); //imprime ese byte en el monitor serial
header += c;
if (c =='
'){//si el byte es un caracter de salto de linea
//si la nueva linea est en blanco significa que es el fin del
//HTTP request del cliente, entonces respondemos:
if(currentLine.length()==0){
client.println("HTTP/1.1200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
if(header.indexOf("GET /onright1")>=0){
Serial.println("GPIO onright1");
estadosalida1="on";
d1=true;
}else if(header.indexOf("GET /onleft1")>=0){
Serial.println("GPIO onleft1");
estadosalida2="on";
i1=true;
}else if(header.indexOf("GET /onright2")>=0){
Serial.println("GPIO onright2");
estadosalida3="on";
d2=true;
}else if(header.indexOf("GET /onleft2")>=0){
Serial.println("GPIO onleft2");
estadosalida4="on";
i2=true;
}else if(header.indexOf("GET /onright3")>=0){
Serial.println("GPIO onright3");
estadosalida5="on";
d3=true;
}else if(header.indexOf("GET /onleft3")>=0){
Serial.println("GPIO onleft3");
estadosalida6="on";
i3=true;
}else if (header.indexOf("GET /close")>=0){
Serial.println("GPIO close");
estadosalida7="on";
cl=true;
}else if (header.indexOf("GET /open")>=0){
Serial.println("GPIO open");
estadosalida7= "off";
cl=false;
}else if(header.indexOf("GET /stop")>=0){
Serial.println("GPIO stop");
estadosalida1= "off";
estadosalida2= "off";
estadosalida3= "off";
estadosalida4= "off";
estadosalida5= "off";
estadosalida6= "off";
d1=false;
d2=false;
d3=false;
i1=false;
i2=false;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions