Hallo
habe es hin bekommen. Jetzt habe ich nur noch folgendes Problem. Ich bekomme die gesendete Nachricht nicht in der richtigen Reihenfolge zurück siehe Bild
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2);
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,178, 50);
IPAddress gateway(192,168,178, 1);
IPAddress subnet(255, 255, 255, 0);
EthernetServer server(2500);
boolean alreadyConnected = false;
char thisChar[10];
int i;
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Starten");
lcd.setCursor(0,1);
lcd.print("System");
delay( 3000);
lcd.clear();
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Chat server address:");
Serial.println(Ethernet.localIP());
}
void loop() {
// wait for a new client:
EthernetClient client = server.available();
// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clead out the input buffer:
client.flush();
Serial.println("We have a new client");
client.println("Verbunden");
alreadyConnected = true;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Verbunden ");
delay( 5000);
lcd.clear();
}
if (client.available() > 0) {
for (i = 0; i < 11; i++) {
// read the bytes incoming from the client:
thisChar = client.read();
- }*
- // echo the bytes back to the client:*
- server.write(thisChar);*
- // echo the bytes to the server as well:*
- Serial.write(thisChar);*
- lcd.clear();*
- lcd.print(thisChar);*
- delay( 100);*
- }*
- }*
}
SPS DB
