Created
December 2, 2015 20:05
-
-
Save elmarcoh/dc7414838ec36a9e2edb to your computer and use it in GitHub Desktop.
Arduino Wifi
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 <SoftwareSerial.h> | |
SoftwareSerial ESP8266(2, 3); | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); //HARDWARE | |
ESP8266.begin(9600);//SOFTWARE | |
enviar_dato("AT", 1000); | |
} | |
void loop() { | |
/*/ put your main code here, to run repeatedly: | |
if(Serial.available()){ | |
char c = Serial.read(); | |
ESP8266.print(c); | |
} | |
if(ESP8266.available()){ | |
char c = ESP8266.read(); | |
Serial.print(c); | |
} | |
*/ | |
} | |
String enviar_dato(String comando, int delay_) { | |
String respuesta = ""; | |
ESP8266.println(comando); | |
long tiempo = millis(); | |
while ( (tiempo + delay_) > millis()) { | |
while (ESP8266.available()) { | |
char c = ESP8266.read(); | |
respuesta += c; | |
} | |
} | |
Serial.print(respuesta); | |
return respuesta; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment