Withe code:
//#include <Ethernet2.h>
//#include <EthernetUdp2.h>
#include <MCUFRIEND_kbv.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>
MCUFRIEND_kbv tft;
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.
//Technical support:goodtft@163.com
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
// #define LCD_CS A3 // Chip Select goes to Analog 3
// #define LCD_CD A2 // Command/Data goes to Analog 2
// #define LCD_WR A1 // LCD Write goes to Analog 1
// #define LCD_RD A0 // LCD Read goes to Analog 0
//#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Adafruit_TFTLCD tft;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x15
};
IPAddress ip(192, 168, 2, 215);
unsigned int localPort = 12080; // local port to listen on
// buffers for receiving and sending data
char packetBuffer[500]; //buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// disable SD card
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
Ethernet.init(10);
Ethernet.begin(mac, ip);
Serial.begin(9600);
tft.reset();
tft.begin(0x9486);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println(F("TFT LCD test"));
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
Udp.begin(localPort);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if (packetSize) {
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = Udp.remoteIP();
for (int i = 0; i < 4; i++) {
Serial.print(remote[i], DEC);
if (i < 3) {
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
Udp.read(packetBuffer,500);
Serial.println("Contents:");
Serial.println(packetBuffer);
String myString = String(packetBuffer);
int Index1 = myString.indexOf(';');
int Index2 = myString.indexOf(';', Index1+1);
int Index3 = myString.indexOf(';', Index2+1);
int Index4 = myString.indexOf(';', Index3+1);
int Index5 = myString.indexOf(';', Index4+1);
int Index6 = myString.indexOf(';', Index5+1);
int Index7 = myString.indexOf(';', Index6+1);
int Index8 = myString.indexOf(';', Index7+1);
int Index9 = myString.indexOf(';', Index8+1);
int Index10 = myString.indexOf(';', Index9+1);
int Index11 = myString.indexOf(';', Index10+1);
int Index12 = myString.indexOf(';', Index11+1);
int Index13 = myString.indexOf(';', Index12+1);
int Index14 = myString.indexOf(';', Index13+1);
int Index15 = myString.indexOf(';', Index14+1);
int Index16 = myString.indexOf(';', Index15+1);
int Index17 = myString.indexOf(';', Index16+1);
int Index18 = myString.indexOf(';', Index17+1);
int Index19 = myString.indexOf(';', Index18+1);
int Index20 = myString.indexOf(';', Index19+1);
int Index21 = myString.indexOf(';', Index20+1);
int Index22 = myString.indexOf(';', Index21+1);
String regel = myString.substring(Index1, Index1);
String regel1 = myString.substring(Index1+1, Index2);
String regel21 = myString.substring(Index2+1, Index3);
String regel22 = myString.substring(Index3+1, Index4);
String regel31 = myString.substring(Index4+1, Index5);
String regel32 = myString.substring(Index5+1, Index6);
String regel41 = myString.substring(Index6+1, Index7);
String regel42 = myString.substring(Index7+1, Index8);
String regel51 = myString.substring(Index8+1, Index9);
String regel52 = myString.substring(Index9+1, Index10);
String regel61 = myString.substring(Index10+1, Index11);
String regel62 = myString.substring(Index11+1, Index12);
String regel71 = myString.substring(Index12+1, Index13);
String regel72 = myString.substring(Index13+1, Index14);
String regel81 = myString.substring(Index14+1, Index15);
String regel82 = myString.substring(Index15+1, Index16);
String regel91 = myString.substring(Index16+1, Index17);
String regel92 = myString.substring(Index17+1, Index18);
String regel101 = myString.substring(Index18+1, Index19);
String regel102 = myString.substring(Index19+1, Index20);
String regel111 = myString.substring(Index20+1, Index21);
String regel112 = myString.substring(Index21+1, Index22);
Serial.println(regel);
Serial.println(regel21);
Serial.println(regel22);
Serial.println(regel31);
Serial.println(regel32);
Serial.println(regel41);
Serial.println(regel42);
Serial.println(regel51);
Serial.println(regel52);
Serial.println(regel61);
Serial.println(regel62);
Serial.println(regel71);
Serial.println(regel72);
Serial.println(regel81);
Serial.println(regel82);
Serial.println(regel91);
Serial.println(regel92);
Serial.println(regel101);
Serial.println(regel102);
Serial.println(regel91)+(regel111);
Serial.println(regel112);
char cell[regel92.length() + 1];
regel92.toCharArray(cell, sizeof(cell));
int n;
n = atoi(cell);
tft.setRotation(3);
tft.fillScreen(BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
tft.setTextColor(RED); tft.setTextSize(8);
tft.println(regel1);
tft.setTextColor(GREEN); tft.setTextSize(3);
tft.println(regel21+regel22);
tft.println(regel31+regel32);
tft.println(regel41+regel42);
tft.println(regel51+regel52);
tft.println(regel61+regel62);
tft.println(regel71+regel72);
tft.println(regel81+regel82);
if (n >= 250) {
tft.setTextColor(RED);
tft.println(regel91+regel92);
// if(regel112>"0") {
//tft.setTextColor(RED); tft.setTextSize(6);
// tft.println(regel111+regel112);
}
else {
tft.println(regel91+regel92);
tft.println(regel101+regel102);
if(regel112>"0") {
tft.setTextColor(RED); tft.setTextSize(6);
tft.println(regel111+regel112);
}
else {
delay (1);
}}}}