Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial mySerial(2, 3); //RX,TX
  4.  
  5. // Arduino pin 2 (RX) to ESP8266 TX
  6. // Arduino pin 3 to voltage divider then to ESP8266 RX
  7. // Connect GND from the Arduiono to GND on the ESP8266
  8. // Pull ESP8266 CH_PD HIGH
  9.  
  10. // When a command is entered in to the serial monitor on the computer
  11. // the Arduino will relay it to the ESP8266
  12.  
  13.  
  14. int LEDPIN = 13;
  15.  
  16. void setup()
  17. {
  18. pinMode(LEDPIN, OUTPUT);
  19.  
  20. Serial.begin(9600); // communication with the host computer
  21. //while (!Serial) { ; }
  22.  
  23. // Start the software serial for communication with the ESP8266
  24. mySerial.begin(115200);
  25.  
  26. Serial.println("");
  27. Serial.println("Remember to to set Both NL & CR in the serial monitor.");
  28. Serial.println("Ready");
  29. Serial.println("");
  30. }
  31.  
  32. void loop()
  33. {
  34. // listen for communication from the ESP8266 and then write it to the serial monitor
  35. if ( mySerial.available() ) { Serial.write( mySerial.read() ); }
  36.  
  37. // listen for user input and send it to the ESP8266
  38. if ( Serial.available() ) { mySerial.write( Serial.read() ); }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement