Advertisement
sudipadhk

not updating

May 10th, 2021
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include <Ethernet.h>
  2. #include <SPI.h>
  3. #include <Adafruit_GFX.h>    
  4. #include <Adafruit_ST7735.h>
  5. #define TFT_CS    10
  6. #define TFT_RST   8  
  7. #define TFT_DC    9
  8. #define TFT_SCLK 13  
  9. #define TFT_MOSI 11  
  10.  
  11. Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);
  12.  
  13. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  14. byte ip[] = { 192, 168, 10, 101 };
  15. byte server[] = { 192, 168, 10, 100 };
  16.  
  17. EthernetClient client;
  18.  
  19. void setup()
  20. {
  21.   Ethernet.begin(mac, ip);
  22.   delay(2000);
  23.  
  24.   tft.initR(INITR_BLACKTAB);  
  25.   tft.fillScreen(ST7735_BLACK);
  26.   tft.setTextColor(ST7735_WHITE);
  27.   tft.setTextSize(0);
  28.   tft.setCursor(30,80);
  29.   tft.println("Connecting...");
  30.   delay(1000);
  31.  
  32.   if (client.connect(server, 80))
  33.   {   tft.fillScreen(ST7735_BLACK);
  34.       tft.setTextColor(ST7735_WHITE);
  35.       tft.setTextSize(0);
  36.       tft.setCursor(50,80);
  37.       tft.println("Welcome");
  38.   }
  39.   else
  40.   {   tft.fillScreen(ST7735_BLACK);
  41.       tft.setTextColor(ST7735_WHITE);
  42.       tft.setTextSize(0);
  43.       tft.setCursor(10,80);
  44.       tft.println("Connection failed");
  45.       Serial.println("connection failed");
  46.   }
  47.      
  48. }
  49.  
  50. void loop()
  51.     {
  52.      client.println("GET /website/php_for_arduino/getcoridor.php HTTP/1.0");
  53.      client.println();
  54.      if (client.available()) {
  55.         String line = client.readString();
  56.         tft.fillScreen(ST7735_WHITE);
  57.         tft.setTextColor(ST7735_BLACK);
  58.         tft.setTextSize(0);
  59.         tft.setCursor(0,0);
  60.         tft.println(&line[216]);
  61.       }
  62.     delay(5000);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement