As referred to the subject line, I am looking at using telnet to turn pin 13 on and off.
I will use this to connect to a relay board that will be connected to my gate keyfob to open my gate.
So my goal is to send the command "open" via telnet and to open my gate.
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192,168,1, 44);
IPAddress gateway(192,168,1, 254);
IPAddress subnet(255, 255, 0, 0);
// telnet defaults to port 23
EthernetServer server(23);
boolean alreadyConnected = false; // whether or not the client was connected previously
void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
pinMode(13, OUTPUT);
}
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();
alreadyConnected = true;
}
if (client.available() > 0) {
// read the bytes incoming from the client: ~ I dont think I want to read the bytes, but a
char thisChar = client.read();
// if open command sent then : ~ What command would I need here ?
//{
// digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
// delay(500); // wait for a second
// digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
//}
}
}
}
Here is my code, if someone could show me the missing part of my code I would be very appreciated.