hello!
so, relatively new in arduino world, yes, i'm n00b
ok, know basics of arduino. now, here thing. have arduino uno , ethernet shield connected router. phone (ios) want turn off led on selected pin (let's turn off led on digital pin 13).
how can achieve this?
and fun, let's assume phone , ethernet shield not on same network.
i thinking in way: app on phone send "turn off pin 13" request on website, , website need send request on router ethernet shield , then...arduino process , on.
is correct way? did did this? if yes, there tutorial on project?
thank you!
regards,
golobich
so, relatively new in arduino world, yes, i'm n00b

ok, know basics of arduino. now, here thing. have arduino uno , ethernet shield connected router. phone (ios) want turn off led on selected pin (let's turn off led on digital pin 13).
how can achieve this?
and fun, let's assume phone , ethernet shield not on same network.
i thinking in way: app on phone send "turn off pin 13" request on website, , website need send request on router ethernet shield , then...arduino process , on.
is correct way? did did this? if yes, there tutorial on project?
thank you!
regards,
golobich
basic client /server control code.
code: [select]
//zoomkat 10-6-13
//simple button iframe code
//open serial monitor see arduino receives
//use ' instead of " in html ilnes
//address http://192.168.1.102:84/ when submited
//for use w5100 based ethernet shields
#include <spi.h>
#include <ethernet.h>
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed }; //ethernet shield mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
ethernetserver server(84); //server port
string readstring;
//////////////////////
void setup(){
pinmode(4, output); //pin selected control
//start ethernet
ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
//enable serial data print
serial.begin(9600);
serial.println("servertest1"); // can keep track of loaded
}
void loop(){
// create client connection
ethernetclient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char char http request
if (readstring.length() < 100) {
//store characters string
readstring += c;
//serial.print(c);
}
//if http request has ended
if (c == '\n') {
///////////////
serial.println(readstring); //print serial monitor debuging
//now output html data header
if(readstring.indexof('?') >=0) { //don't send new page
client.println("http/1.1 204 zoomkat\r\n\r\n");
}
else {
client.println("http/1.1 200 ok"); //send new page
client.println("content-type: text/html");
client.println();
client.println("<html>");
client.println("<head>");
client.println("<title>arduino test page</title>");
client.println("</head>");
client.println("<body>");
client.println("<h1>zoomkat's simple arduino button</h1>");
client.println("<a href='/?on1' target='inlineframe'>on</a>");
client.println("<a href='/?off' target='inlineframe'>off</a>");
client.println("<iframe name=inlineframe style='display:none'>");
client.println("</iframe>");
client.println("</body>");
client.println("</html>");
}
delay(1);
//stopping client
client.stop();
///////////////////// control arduino pin
if(readstring.indexof("on1") >0)//checks on
{
digitalwrite(4, high); // set pin 4 high
serial.println("led on");
}
if(readstring.indexof("off") >0)//checks off
{
digitalwrite(4, low); // set pin 4 low
serial.println("led off");
}
//clearing string next read
readstring="";
}
}
}
}
}
Arduino Forum > Using Arduino > Project Guidance > Control arduino with phone, over the internet
arduino
Comments
Post a Comment