I need to create a web client with Arduino and Ethernet Shield and several possible combinations never got a valid IP for the Arduino .
Ethernet.begin ( mac ) the system stops on this line. To begin ( mac, ip) the system assigns the IP 0.25.25.25 . Already blocked the SD card system with the pin 4 to LOW and HIGH , already used the begin ( mac, ip , dns , gateway mask ) and the result was the same attachment the last code. The idea is to run a php page that inserts a record in mysql table.
#include <Ethernet.h>
#include <SPI.h>
EthernetClient client;
byte mac[] = { 144, 162, 218, 16, 66, 237 };
byte ip[] = { 192, 168, 1, 151 };
byte mydns[] = { 192, 168, 1, 1 };
byte gateway[] = { 192, 168, 1, 1 };
byte mask[] = { 255, 255, 255, 0 };
byte server[] = { 192, 168, 1, 150 };
void setup()
{
Ethernet.begin(mac,ip); //, mydns, gateway, mask);
delay(1000);
pinMode(4, OUTPUT);
//pinMode(10, OUTPUT);
//digitalWrite(10, LOW);
digitalWrite(4, HIGH);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
Serial.print(Ethernet.localIP());
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("/arduino/index.php");
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
}