i have a arduino uno and a enthernet shield and two button
my question is can someone create a program to ping a website. one button per site. sites I will be pinged once per press. is
and
it is just for light control
please make the program for me
i have a arduino uno and a enthernet shield and two button
my question is can someone create a program to ping a website. one button per site. sites I will be pinged once per press. is
and
it is just for light control
please make the program for me
Check out the WebClient example sketch provided with the ethernet library.
Just change the URL and there you have it.
where i can find the web client
\arduino\libraries\Ethernet\examples\WebClient
i find i now but how can i put both url in this code and how to use the two button
If this is the first time you write code, I suggest you start with the Blink example (C:\arduino\arduino-1.0.6\examples\01.Basics\Blink)
i have code before but i dont understand so complicatet programs with enthernet
Every journey starts with a single step.
Do yourself a favour and upload the WebClient sketch as is. See how it works (open the serial monitor).
Then, change the URL from google.com to yours.
Then look at this example on how to read a button.
Once you understood that, combine the 2 examples. It's not that complicated.
Client test code that sends a get request to a server, then captures the server's returned reply, then extracts data from that server reply.
//zoomkat 11-04-13
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test client GET
//for use with W5100 based ethernet shields
//remove SD card if inserted
//data from myIP server captured in readString
#include <SPI.h>
#include <Ethernet.h>
String readString, data;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
char serverName[] = "api.thingspeak.com"; // myIP server test web page server
EthernetClient client;
//////////////////////
void setup(){
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
Serial.begin(9600);
Serial.println("client readString test 11/04/13"); // so I can keep track of what is loaded
Serial.println("Send an e in serial monitor to test"); // what to do to test
Serial.println();
}
void loop(){
// check for serial input
if (Serial.available() > 0) //if something in serial buffer
{
byte inChar; // sets inChar as a byte
inChar = Serial.read(); //gets byte from buffer
if(inChar == 'e') // checks to see byte is an e
{
sendGET(); // call sendGET function below when byte is an e
}
}
}
//////////////////////////
void sendGET() //client function to send/receive GET request data.
{
if (client.connect(serverName, 80)) { //starts client connection, checks for connection
Serial.println("connected");
client.println("GET /channels/21652/fields/3/last HTTP/1.1"); //download text
client.println("Host: api.thingspeak.com");
client.println("Connection: close"); //close 1.1 persistent connection
client.println(); //end of get request
}
else {
Serial.println("connection failed"); //error message if no client connect
Serial.println();
}
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
readString += c; //places captured byte in readString
}
//Serial.println();
client.stop(); //stop client
Serial.println("client disconnected.");
Serial.println("Data from server captured in readString:");
Serial.println();
Serial.print(readString); //prints readString to serial monitor
Serial.println();
Serial.println();
Serial.println("End of readString");
Serial.println("==================");
Serial.println();
int loc = readString.indexOf("4\r\n");
data = readString.substring(loc+3, loc+9);
Serial.print("data is: ");
Serial.println(data);
Serial.println();
readString=""; //clear readString variable
data="";
}