Go Down

Topic: Telnet Led Control (Read 582 times) previous topic - next topic

JakeDuino

May 26, 2013, 04:43 am Last Edit: May 26, 2013, 07:27 am by JakeDuino Reason: 1
Simple Telnet Client Led Control

//Telnet Led Contol

// Etherned and SPI
#include <SPI.h>
#include <Ethernet.h>

// I am using an green led for this project , you can obviously change this
int greenled   = 9;


// MAC is software-set.
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0x5B };

// set your own network information as follows
IPAddress ip(129,173,97,17);
IPAddress gateway(129,173,96,1);
IPAddress subnet(255, 255, 254, 0);


EthernetServer telnetServer = EthernetServer(23);


void setup() {
 pinMode(greenled, OUTPUT);
 
 Serial.begin(9600);  
 Serial.print("System Start");
 
 
 Ethernet.begin(mac, ip, gateway, subnet);

 
 telnetServer.begin();
 Serial.print("Started the Servers\n");
 
}

void loop() {
 
 
 EthernetClient telnetClient = telnetServer.available();

 if (telnetClient) {
   boolean updatedState = false;
   
   char telnetValue = telnetClient.read();
   
   switch (telnetValue) {
     case '0':
       updatedState = true;
       digitalWrite (greenled, LOW);
       break;
     case '1':
       updatedState = true;
       digitalWrite(greenled, HIGH);
       break;

   }
 }
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy