Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1.  
  2. #include <ESP8266WiFi.h>
  3. #include <LiquidCrystal.h>
  4. const char* ssid = "embarcados";
  5. const char* password = "embarcados";
  6. const int ledPin = 2;
  7. WiFiServer server(32000);
  8.  
  9.  
  10. void printWiFiStatus();
  11.  
  12. void setup(void) {
  13.  
  14. Serial.begin(115200);
  15.  
  16. WiFi.begin(ssid, password);
  17.  
  18. // Configure GPIO2 as OUTPUT.
  19. pinMode(ledPin, OUTPUT);
  20.  
  21. // Start TCP server.
  22. server.begin();
  23. printWiFiStatus();
  24. }
  25.  
  26. void loop(void) {
  27. // Check if module is still connected to WiFi.
  28. uint8_t command[30];
  29. if (WiFi.status() != WL_CONNECTED) {
  30. while (WiFi.status() != WL_CONNECTED) {
  31. delay(500);
  32. }
  33. // Print the new IP to Serial.
  34.  
  35. }
  36.  
  37. WiFiClient client = server.available();
  38.  
  39. if (client) {
  40. Serial.println("Client connected.");
  41.  
  42. while (client.connected()) {
  43. if (client.available()) {
  44. //char command = client.read();
  45.  
  46. String line = client.readStringUntil('/');
  47. Serial.println(line);
  48. display_data(line);
  49. /* if (command == 'H') {
  50. digitalWrite(ledPin, HIGH);
  51. Serial.println("LED is now on.");
  52. }
  53. else if (command == 'L') {
  54. digitalWrite(ledPin, LOW);
  55. Serial.println("LED is now off.");
  56. }
  57.  
  58. Serial.println(command);*/
  59. }
  60. }
  61. Serial.println("Client disconnected.");
  62. client.stop();
  63. }
  64.  
  65. delay(500);
  66. }
  67.  
  68. void printWiFiStatus() {
  69. Serial.println("");
  70. Serial.print("Connected to ");
  71. Serial.println(ssid);
  72. Serial.print("IP address: ");
  73. Serial.println(WiFi.localIP());
  74. }
  75.  
  76. void display_data(String temp){
  77. const int rs = 0, en = 15, d4 = 13, d5 = 12 , d6 = 14, d7 = 16; // temque mudar
  78. LiquidCrystal lcd(rs,en,d4,d5,d6,d7); // config
  79. lcd.begin(16,2);
  80. lcd.setCursor(0,0); // zero 1
  81. lcd.print(temp);
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement