I am working with a Seed Studio 1.1 ethernet shield on an Arduino Uno and a set up code out of the Arduino Cookbook.
The code seems to be working. When I go to the serial port it reads connecting … no connection, disconnecting. I don’t know if there is an issue with the IP addresses or the MAC address or if it’s something else entirely.
The boards only indicated address is 12A12. I’ve tried {0x1, 0x2, 0x1, 0x0, 0x1, 0x2}, the original code’s address {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}, and the ethernet MAC address as read off my computer ethernet network in system preferences {0xc8, 0xbc, 0xc8, 0x91, 0x49, 0x52}.
I’ve also tried switching between the Airport IP address and Ethernet IP address. The ethernet IP consistently changes with each new attempt to connect.
I’ve added the router IP address under one and both dns_server and gateway. I’ve also used the computers Ping utility to locate a current google IP address.
I am very new to all of this and learning as I go. Can anyone tell me what I should try next to get a connection. Thank you in advance for your patience, time and attention.
Here is the code:
/*
- Simple Web Client
- Arduino 1.0 version
*/
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,254,30 }; //AirPort IP
byte server[] = { 74,125,225,148 }; //Google
byte gateway[] = { 192,168,254,30 }; //router
EthernetClient client;
void setup()
{
Serial.begin(9600); //start the serial library
Ethernet.begin(mac,ip,gateway);
delay(1000); //give the ethernet hardware a second to initialize
Serial.println(“connecting…”);
if (client.connect(server, 80)) {
Serial.println(“connected”);
client.println(“GET /search?q=arduino HTTP/1.0”); //the HTTP request
client.println();
}
else {
Serial.println(“connection failed”);
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print©; //echo all data recieved to the serial monitor
}
if (!client.connected()) {
Serial.println();
Serial.println(“disconnecting.”);
client.stop();
for(;smiley-wink
;
}
}