Advertisement
NapsterMP3

ATC PRO wemos Test

Jul 4th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1.  
  2.  
  3. //#include <SPI.h>
  4. //#include <Ethernet.h>
  5. #include <ESP8266WiFi.h>
  6. const char* ssid = "EVERTON";
  7. const char* password = "qwertyui";
  8.  
  9.  
  10. // Special commands
  11. #define CMD_SPECIAL '<'
  12. #define CMD_ALIVE '['
  13.  
  14. // Enter a MAC address and IP address for your controller below.
  15. // The IP address will be dependent on your local network:
  16. //byte mac[] = {
  17. // 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  18. //IPAddress ip(192,168,1,60);
  19.  
  20. // Initialize the Ethernet server library
  21. // with the IP address and port you want to use
  22. // (port 80 is default for HTTP):
  23.  
  24. WiFiServer server(80);
  25.  
  26. //EthernetServer server(80);
  27. //EthernetClient client;
  28.  
  29. void setup() {
  30. Serial.begin(115200);
  31. delay(10);
  32.  
  33. pinMode(2, OUTPUT);
  34. pinMode(2, LOW);
  35.  
  36. Serial.println();
  37. Serial.println();
  38. Serial.print("Connecting to ");
  39. Serial.println(ssid);
  40.  
  41. WiFi.begin(ssid, password);
  42.  
  43. //Ethernet.begin(mac, ip);
  44.  
  45. while (WiFi.status() != WL_CONNECTED) {
  46. delay(500);
  47. Serial.print(".");
  48. }
  49. Serial.println("");
  50. Serial.println("WiFi connected");
  51.  
  52. server.begin();
  53. Serial.println("Server started");
  54. Serial.println(WiFi.localIP());
  55.  
  56. server.println("Thanks for your support");
  57. }
  58.  
  59. void loop() {
  60. int appData;
  61.  
  62. // ===========================================================
  63. // This is the point were you get data from the App
  64. WiFiClient client = server.available();
  65. if (client){
  66. appData = client.read();
  67. }
  68. switch(appData){
  69. case 'A': // Turn on pin 2
  70. digitalWrite(2, HIGH);
  71. break;
  72.  
  73. case 'a': // turn off pin 2
  74. digitalWrite(2, LOW);
  75. break;
  76.  
  77. case CMD_SPECIAL:
  78. // I hope you did not enabled accelerometer or seek bars, so this will never be called
  79. break;
  80.  
  81. case CMD_ALIVE:
  82. // Character '[' is received every 2.5s, use
  83. // this event to tell the android we are still here
  84. server.println("Please move to example code");
  85. break;
  86. }
  87. // ==========================================================
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement