Created
July 3, 2014 08:06
-
-
Save companje/cf8db122687ae99ef244 to your computer and use it in GitHub Desktop.
Arduino socket server forwarding all data received on Serial port to all connected clients
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <Ethernet.h> | |
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; | |
IPAddress ip(192,168,2, 177); | |
IPAddress gateway(192,168, 2, 100); | |
IPAddress subnet(255, 255, 255, 0); | |
EthernetServer server(23); | |
void setup() { | |
Ethernet.begin(mac, ip, gateway, subnet); | |
server.begin(); | |
Serial.begin(9600); | |
Serial.print("Server address:"); | |
Serial.println(Ethernet.localIP()); | |
} | |
void loop() { | |
while (Serial.available()>0) { | |
char ch = Serial.read(); | |
server.write(ch); | |
Serial.write(ch); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment