Advertisement
sudipadhk

loop not running

May 10th, 2021
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 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.   {
  34.       tft.fillScreen(ST7735_BLACK);
  35.       tft.setTextColor(ST7735_WHITE);
  36.       tft.setTextSize(0);
  37.       tft.setCursor(50,80);
  38.       tft.println("Welcome");
  39.       client.println("GET /website/php_for_arduino/getcoridor.php HTTP/1.0");
  40.       client.println();
  41.   }
  42.   else
  43.   {    
  44.       tft.fillScreen(ST7735_BLACK);
  45.       tft.setTextColor(ST7735_WHITE);
  46.       tft.setTextSize(0);
  47.       tft.setCursor(10,80);
  48.       tft.println("Connection failed");
  49.       Serial.println("connection failed");
  50.   }
  51.      
  52. }
  53.  
  54. void loop()
  55.     {
  56.   if (client.available()) {
  57.     String line = client.readString();
  58.     tft.fillScreen(ST7735_WHITE);
  59.     tft.setTextColor(ST7735_BLACK);
  60.     tft.setTextSize(0);
  61.     tft.setCursor(0,0);
  62.     tft.println(&line[216]);
  63.   }
  64.     delay(5000);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement