Unable to connect ethernet shield to internet
hi, trying connect arduino twitter using ethernet sheild. unable connect website. think arduino getting ip assigned , think problem @ client.connect() function. pls me. here code
code: [select]
#include <spi.h>
#include <ethernet.h>
byte mac[] = { 0x90, 0xa2, 0xdf, 0xc4, 0x70, 0x69 }; // mac address of arduino ethernet shield
byte ip[] = { 192,168,1,177 }; // ip assigned arduino
byte gateway[] = { 192,168,1,1 }; // gateway address
byte subnet[] = { 255,255,255,0 }; // subnet mask address
byte server[] = {199, 59, 148, 10 }; // ip address of twitter
ethernetclient client;
void setup()
{
serial.begin(9600);
serial.println("program initailising...");
delay(2000);
ethernet.begin(mac, ip, subnet, gateway);
delay(1000);
serial.println("connecting...");
}
void loop()
{ if(client.connect(server,80))
{
client.println("get http://www.twitter.com/statuses/user_timeline/hautomation.rss http/1.0"); // senting request twitter
client.println();
}
else
{
serial.println("unable connect twitter");
}
// if there incoming bytes available
// server, read them , print them:
if (client.available()) {
char c = client.read();
serial.print(c);
}
// if server's disconnected, stop client:
if (!client.connected()) {
serial.println();
serial.println("disconnecting.");
client.flush();
client.stop();
}
}
if using arduino 1.0 arguments ethernet.begin() have changed. best bet pass mac address , let dhcp assign else.
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Unable to connect ethernet shield to internet
arduino
Comments
Post a Comment