# Control arduino with phone, over the internet

**URL:** <https://forum.arduino.cc/t/control-arduino-with-phone-over-the-internet/335213>\
**Category:** General Guidance\
**Created:** [September 15, 2015, 2:49pm UTC](https://forum.arduino.cc/t/control-arduino-with-phone-over-the-internet/335213 "2015-09-15T14:49:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![golobich](https://avatars.discourse-cdn.com/v4/letter/g/e79b87/32.png) [@golobich](https://forum.arduino.cc/u/golobich)\
**Post date:** [September 15, 2015, 2:49pm UTC](https://forum.arduino.cc/t/control-arduino-with-phone-over-the-internet/335213/1 "2015-09-15T14:49:11Z")

</div>

Hello!

So, I am relatively new in Arduino world, so yes, I'm a n00b 🙂

Ok, I know the basics of arduino. But now, here is the thing. I have Arduino UNO and Ethernet shield connected to router. With my phone (iOS) I want to turn off the LED on selected pin (let's say to turn off the LED on digital pin 13).

How can I achieve this?

And just for fun, let's assume that phone and ethernet shield are not on the same network.

I was thinking in this way: My app on phone will send "turn off pin 13" request on my website, and then this website will need to send this request on my router for ethernet shield and then...arduino will process this and so on.

Is this the correct way? Did anyone already did this? If yes, is there tutorial on this project?

Thank you!

Regards,  
golobich

---

<div class="post-metadata">

**Author:** ![zoomkat](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zoomkat/32/1190177_2.png) [@zoomkat](https://forum.arduino.cc/u/zoomkat)\
**Post date:** [September 16, 2015, 1:18am UTC](https://forum.arduino.cc/t/control-arduino-with-phone-over-the-internet/335213/2 "2015-09-16T01:18:32Z")

</div>

Basic client /server control code.

```cpp
//zoomkat 10-6-13
//simple button GET with iframe code
//open serial monitor to see what the arduino receives
//use the ' instead of " in html ilnes 
//address will look like http://192.168.1.102:84/ when submited
//for use with 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 to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("servertest1"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for 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 GET 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 for on
          {
            digitalWrite(4, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(4, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![scottyjr](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@scottyjr](https://forum.arduino.cc/u/scottyjr)\
**Post date:** [September 16, 2015, 11:33am UTC](https://forum.arduino.cc/t/control-arduino-with-phone-over-the-internet/335213/3 "2015-09-16T11:33:17Z")

</div>

Perhaps [Blynk](http://www.blynk.cc/) ? - Scotty

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 5:36pm UTC](https://forum.arduino.cc/t/control-arduino-with-phone-over-the-internet/335213/4 "2021-05-05T17:36:39Z")

</div>

Closed on May 5, 2021, 5:36pm UTC


