Pages: [1]   Go Down
Author Topic: Telnet Led Control  (Read 467 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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;

    }
  }
}
« Last Edit: May 26, 2013, 12:27:24 am by JakeDuino » Logged

Pages: [1]   Go Up
Jump to: