Thursday, May 21, 2009

Arduino Ethernetsheidl code.

I couldn't find any on line code to check the ethershield working on Arduino so here is mine. You need telnet.

#include
#include
#include

/*
* Chat
* this is an example of the simplist possible hello world
* program. Use telnet to talk to the machine
* telnet ipaddress you give the machine.
*/
int boardLED = 13 ;
int ledPin = 12; // LED connected to digital pin 13
int greenLED = 11;



byte mac[] = { 0x85, 0xDC, 0x1D, 0x14, 0xD7, 0x53 }; // second mac address 85:DC:1D:14:D7:53
byte ip[] = { 169,254,74,14 };// find your own network address
byte gateway[] = { 169,254,74,32 };
byte subnet[] = { 255, 255, 0, 0 };
Server server = Server(23);

//int thing[12];

void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(greenLED, OUTPUT ) ;
pinMode(boardLED, OUTPUT ) ;
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
}

void loop() // run over and over again
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(random(0, 250));
digitalWrite(boardLED, HIGH);
delay(random(0, 250));
digitalWrite(greenLED, LOW);
delay(random(0, 500)); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
digitalWrite(greenLED, HIGH);
delay(random(0, 1000)); // waits for a second
digitalWrite(boardLED, LOW);
Client client = server.available();
if (client) {
server.write(client.read());
}
}

No comments: