Sunday, March 13, 2016

arduino telnet server

this is the code for an telnet server
with nokia 5110 display used to output
messages from conected computers
—————————————————————————
#include SPI.h
#include Ethernet.h
#include LCD4884.h

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0×20, 0×13 };
IPAddress ip(192,168,178,5);
IPAddress gateway(192,168,178, 1);
IPAddress subnet(255, 255, 255, 0);

static LCD4884 lcd;

EthernetServer server(23);
boolean gotAMessage = false;
int incomingByte = 0;

void setup() {
lcd.begin(84,48);
lcd.print(”M4TRiX-v5.84”);
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.begin(9600);
}

void loop() {
EthernetClient client = server.available();
if (client) {
if (!gotAMessage) {
Serial.println(”new user online”);
client.println(”W3Lc0M3 t0 Th3 4d 34 54 52 69 58”);
gotAMessage = true;
}

char thisChar = client.read();
server.write(thisChar);
lcd.write(thisChar);
Serial.print(thisChar);
}
}