thank you for viewing. I am trying to obtain basic ethernet functionality from an Ardunio with Ethernet Shield so I can move on to the rest of my application. But no matter what, the ethernet just won't work! All of my hardware is brand new. I have tried both an Arduino UNO and a Mega 2560. I have three ethernet shields. They all produce the same result.. Nothing!
I have tried USB Power only, as well as 6V, 7.5V, and 9V DC on the DC jack. I'm scared to try 12V..
I am running Arduino IDE 1.6.7 on OS X El Capitan.
The LINK, 100M, and FDX LEDS will light when I plug into ethernet. I even see ACT flash when packets hit it.
I also know about writing Pin4 high to prevent SDCARD from interfering, but it had no effect, besides there is no card present.
I'm not sure what else to mention about the enviroment. On to the code.. Below is an example of code that does not work. It makes it into setup and prints "Serial Started" to the serial port, but never makes it through Ethernet.begin(mac, ip). I get the exact same results from the example code on any website I can find.. Ethernet.begin halts the program.
Any ideas? Things I missed? Thanks!
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0x31, 0xBF };
IPAddress ip(192,168,237, 2);
IPAddress gateway(192,168,237, 1);
IPAddress subnet(255, 255, 255, 0);
EthernetServer Server = EthernetServer(80);
void setup() {
// Disable the SDCARD
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Serial Started");
// start the Ethernet connection and the server:
delay(250);
Ethernet.begin(mac, ip);
Server.begin();
Serial.print("Server Started At ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = Server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Refresh: 5");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("
");
}
client.println("</html>");
break;
}
if (c == '\n') {
currentLineIsBlank = true;
} else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}