Hello, I come from the microcontroller programming pic, I'm in the arduino a few time.
I ask your kind help in this example I will be able to explain what I need.
Realize that the variable byte server is declared before the void setup () right? With the IP address, so far so good.
But I need to change this IP (it will be sent via tcp / ip and it is already running a C # application sending) but that is not the case now.
Well it gets the new IP that has to be changed, however in all the ways that I tried to change it .. it does not alter it just keeps looking for the start IP.
If I put the new address in void setp () or void loop () like this: byte server [] = {new address}; It does not update.
please help me!!
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte server[] = { 64, 233, 187, 99 }; // Google
EthernetClient client;
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
/////At a given moment it receives the new ip and changes here below///
byte server[] = { new address }; ///It does not update .. keeps address declared there in the beginning
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}