Skip to content

How to remotely enable/disable a LED on your Arduino using PHP and Processing

Reading time: 3 minutes

Just got your first Arduino, but you don’t have any additional hardware? Gotten a little tired of watching the LED blink by itself, with no interaction? Check this out.

This is the first thing I ever made for Arduino, as I had just received my first Uno and didn’t have any additional hardware. After playing with the included examples and some tutorials I got bored after about an hour (making the internal LED blink is only exciting for so long!).

So I decided to make it a bit more interesting; i wanted to be able to enable and disable the internal LED using a web interface. This is actually quite simple, and could easily be altered to enable remote control of relays or other different types of outputs. The great thing about using a web interface is that it is cross-platform and pretty much enables you to also control your Arduino using most devices with web browsing capabilities, such as smartphones and tablets.

Well, enough talk. Let’s get to it! Here’s what you need:

• An Arduino board with an internal LED (usually on pin 13) or a separate LED
• A webhosting service with PHP support
• The Arduino IDE
• The Processing IDE
• A text editor (e.g. Notepad++, Geany, or whatever you prefer)

First, we’ll start off with the web interface. It’s function is to give the user the choice to either switch the LED on or off. When either one of them is clicked, the command is written to a .txt-file as a 1 (ON) or 0 (OFF) value.
The interface consists of three files; a HTML frontend, a PHP document, and a .txt-file for storing values. So, firstly create these files using a text editor:

    • index.html
    • led.php
    • LEDstate.txt

Index.html should contain the following:

<html>
<head>
<title>LED ON/OFF</title>
</head>
<body>
<!-- This is just for aesthetics, centering the
content within the paragraph -->
<p align="center">
<font size="8">
 
<!-- This part is a a link, which also sends a request to the php-document,
telling it to write 1 or 0 to LEDstate.txt -->
<b><a href="led.php?state=1">ON</a></b> /
<b><a href="led.php?state=0">OFF</a></b></font>
</p>
 
</body>
</html>

 
Here’s an example of what it should look like.

Now for the PHP file :

<?php
$onoroff = $_GET["state"]; // Declares the request from index.html as a variable
$textfile = "LEDstate.txt"; // Declares the name and location of the .txt file

$fileLocation = "$textfile";
$fh = fopen($fileLocation, 'w	') or die("Something went wrong!"); // Opens up the .txt file for writing and replaces any previous content
$stringToWrite = "$onoroff"; // Write either 1 or 0 depending on request from index.html 
fwrite($fh, $stringToWrite); // Writes it to the .txt file 
fclose($fh); 

header("Location: index.html"); // Return to frontend (index.html) 
?>

The .txt file (LEDstate.txt) can be left empty.

Upload these three files to your website, and remember the location. We’re gonna need it for later.

Now it’s time to code the Arduino! For this, we can simply use the “Physical Pixel” example code from the Arduino website, written by David A. Mellis, Tom Igoe and Scott Fitzgerald. We only need the Arduino part of it though, so I’ll copy it onto here. What it does is to open up a serial connection to the host computer and listens for serial inputs. If the Arduino receives the command “H” it sets the LED to “HIGH” (ON), or “LOW” (OFF) if it receives the command “L”. (For more information on this, check out the “blink” tutorial).

const int ledPin = 13; // the pin that the LED is attached to - change this if you have a separate LED connected to another pin
int incomingByte;      // a variable to read incoming serial data into

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    }
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);
    }
  }
}

Upload the sketch to your Arduino using the Arduino IDE. To test if it works, open up the serial port monitor and type either “H” or “L” (without quotation marks), then click send. If the LED turns on and off, you’re good to go! If not, check if the pin variable is set to the actual pin your LED is connected to (if you’re not using the internal one – which usually is at pin 13).

Now for the last part that ties it all together! Open up the Processing IDE and enter the following:

/*

A simple Processing script for enabling or disabling the LED on an Arduino using a web interface and serial communication.
Author: Sindre Lindstad
Created: 19th of January 2011
http://projects.sindrelindstad.com

*/

 import processing.serial.*;
 Serial port;

 void setup()  {

   /* This part must be altered to fit your local settings. The number in brackets after "Serial.list()" is where you declare what COM port your Arduino is connected to.
      If you get error messages, try a different number starting from 0 (e.g. 0, 1, 2, 3...) . */
    port = new Serial(this, Serial.list()[1], 9600);  // Open the port that the Arduino board is connected to, at 9600 baud

}
 void draw() {

  String onoroff[] = loadStrings("http://YOURDOMAIN.COM/LEDstate.txt"); // Insert the location of your .txt file
  print(onoroff[0]);  // Prints whatever is in the file ("1" or "0")

  if (onoroff[0].equals("1") == true) {
    println(" - TELLING ARDUINO TO TURN LED ON");
    port.write('H'); // Send "H" over serial to set LED to HIGH

  } else {

    println(" - TELLING ARDUINO TO TURN LED OFF");
    port.write('L');  // Send "L" over serial to set LED to LOW
 }

  delay(7000); // Set your desired interval here, in milliseconds
 }

Remember to edit it according to the comments. Now you should be all set to hit the Run/Play button! A small empty window will pop up, but your sketch should be running properly and posting messages in the Processing terminal window.

If you haven’t set it to connect to the right serial COM-port it will post an error to the terminal window. If you haven’t set the correct path to your .txt file, it will post “html” instead of “1” or “0”. Also note that you cannot use the Arduino IDE serial port monitor (or any other serial monitor) while running the sketch.

If everything works; – hooray! Show your friends, and have them turn your LED on and off from whereever they might be in the world. If it doesn’t work, review everything and make sure it’s all set up properly. If it still won’t work; leave a comment.

Reddit user tenbatsu jazzed up the Arduino sketch a bit, and made it a little sexier. It’s designed for the use of three (external) LEDs. A blue LED to fade in and out, a green LED that indicates a “ready” state, and a red LED that indicates a “change” state. Have a look!

const int fadePin = 9;    // The pretty blue LED
const int redPin = 10;    // Red LED
const int greenPin = 11;  // Green LED
const int fadeAmount = 5; // Increment to adjust brightness

int incomingByte;   // A variable to read incoming serial data into
int brightness = 0; // How bright the LED is

void setup()  { 
  // Initialize serial communication:
  Serial.begin(9600);

  // Declare outputs:
  pinMode(fadePin, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
} 

void loop()  { 
  // Indicate ready state    
  digitalWrite(greenPin, HIGH);
  digitalWrite(redPin, LOW);

  if (Serial.available() > 0) {
    // Indicate change state
    digitalWrite(redPin, HIGH);
    digitalWrite(greenPin, LOW);

    // See if there's incoming serial data:
    incomingByte = Serial.read();
    
    if (incomingByte == 'H' && brightness < 255) {
      // Cycle the blue LED from dim to bright
      for (brightness = 0; brightness < 255; brightness += fadeAmount) {
        analogWrite(fadePin, brightness);
        delay(30);
      }
    } else if (incomingByte == 'L' && brightness > 0) {
      // Cycle the blue LED from bright to dim
      for (brightness = 255; brightness > 0; brightness -= fadeAmount) {
        analogWrite(fadePin, brightness);
        delay(30);
      }
    }
  }
}

106 Comments

    • waqas waqas

      i am confuse in one thing what is processing ide and arduino ide? should i upload both in arduino or how i m confuse?

  1. nightowl nightowl

    hello, i do this i put the serial port 0 run but nothing happend with the arduino.

    • sindre sindre

      If you add this to the setup-part of the code it will print a list of your available serial ports upon initiating the sketch:

       void setup()  {
       
         /* This part must be altered to fit your local settings. The number in brackets after "Serial.list()" is where you declare what COM port your Arduino is connected to.
            If you get error messages, try a different number starting from 0 (e.g. 0, 1, 2, 3...) . */
          
          println(Serial.list());
          port = new Serial(this, Serial.list()[1], 9600);  // Open the port that the Arduino board is connected to, at 9600 baud
       
      }
      
      

      Then try using one of the serial ports listed in the terminal output.

  2. that’s works… thanks bro…
    i’ll develop to the next my project using relay…

    • I can’t access my text file (LEDstate.text). It shows a 404 error.

  3. @waqas that’s Processing IDE is like an interface of your arduio sketch in Arduino IDE, the analogy like this : Your sketch in arduino IDE is a backend of your project and the Processing sketch in Processing IDE is a front end of user that control your project.

    i hope that’s will help you, i’m sorry my english not good. 😀

  4. hugh hugh

    this line: port = new Serial(this, Serial.list()[1], 9600);
    Im getting arrayoutofbound exception. need help

    • sindre sindre

      You’re probably trying to connect to an unavailable COM-port. First connect the Arduino to your computer, then add this line to the code, and run it. It should list the COM-ports currently used by your computer, before it outputs the ArrayIndexOutOfBoundsException error:

       void setup()  {
       
         /* This part must be altered to fit your local settings. The number in brackets after "Serial.list()" is where you declare what COM port your Arduino is connected to.
            If you get error messages, try a different number starting from 0 (e.g. 0, 1, 2, 3...) . */
          
          println(Serial.list());
          port = new Serial(this, Serial.list()[1], 9600);  // Open the port that the Arduino board is connected to, at 9600 baud
       
      }
      
      

      Here’s an example output:
      [0] “COM1”
      [1] “COM4”

      In this case it means that the Arduino is connected to either COM1, which is identified as number 0, or COM4, which is identified as number 1. I know my Arduino is connected to COM4, so I use number 1: port = new Serial(this, Serial.list()[1], 9600);

      On your computer, however, it might be another number. If it’s 0, you use this parameter:
      port = new Serial(this, Serial.list()[0], 9600);
      or if it’s 2:
      port = new Serial(this, Serial.list()[2], 9600);

      etc.

      • hugh hugh

        thx for you reply. I figured that my arduino is connect to COM3 and it is the only one which shown up. Therefore i change it to port = new Serial(this, Serial.list()[0], 9600);

        Another problem is that, im hosting a server locally with Apache and i put the LEDtext.txt file under etc/cmos/LEDtext.txt and set the corresponding loadStrings(“localhost/cmos/LEDstate.txt”); but its giving me null exception saying the file is not exist. what did i do wrong?

        • hugh hugh

          nvm, i tried to set it as my local directory and it works perfectly nice now 🙂

          I have a question tho, what the purpose of using Processing, can we do something in arduino or just PHP to make the LED be controllable from web?

          • sindre sindre

            If you connect the Arduino directly (through USB) to the web server, you can feed it commands from PHP using serial communication.

            Or you could use an Ethernet Shield to connect the Arduino directly to your local network.

            Otherwise you’ll need a link between the webserver and the Arduino – in this case a computer + Processing.

    • Sanket Chauhan Sanket Chauhan

      change 1 to 0
      It will work

  5. agus joko agus joko

    Help,,

    I try the code, but the led.php cannot save state 0/1 to LEDstate.php,,
    maybe we must declare the location of LEDstate.txt file??? thx

  6. Alex Alex

    Hello,
    I am really interested in your project. I followed your instructions but when i compile the processing program, I get this error: “NullPointerException” while the following line is highlighted:

    print(onoroff[0]); // Prints whatever is in the file (“1” or “0”)

    Could you please help me fix this problem?

    Thanks,
    Alex

  7. Carlo Carlo

    Can i enable a LED remotely with an Arduino Uno and Arduino Ethernet Shield without a computer??

    I made a remote enable of a motor with the mentioned components, but obviously with a PC, want to do the same without a computer, only with Arduino Uno and Arduino Ethernet shield. It’s possible?

  8. siegkorn siegkorn

    Awesome project!!! thanks for sharing!!!

  9. ninjo ninjo

    Thank you so much. Finally i found a code that work fine. The only one. Now in trying to do this on a raspberry pi but processing is giving me a few problems.

  10. limuel limuel

    this is nice.
    but can you help me about my final year project a real time vehicle tracking system with collision detection. the only problem is that i can’t send the data taken from the GPS and send to my web server by GPRS, i’m using arduino atmega644 kit, GPS receiver shield and GSM/GPRS shield. and form my domain server i use DOT.TK a free domain name provider and a 000webhost.com for a free web hosting.

    can you help me about my problem? by the way the data that will be send by gprs will be automatically save to my database it is also online by the use of 000webhost.com, and the data taht is send is the latitude, longitude and the time or the UTC(Universal Time Coordinates).

    i’m looking forward for your help. hope you can help me about this..
    thank you advance…

    [email protected]

  11. sachin muley sachin muley

    Sir..
    we did the above mentioned procedure…there is no error in index.html,processing ide and arduino ide. everything is running properly..after clicking on ON in index.html,the text file LED_state.txt is also getting updated to 0 or 1…but the led is not blinking…what is the problem? need help….

  12. Zainub Zainub

    Hello:
    I want to connect gprs module to an android application. I have teensy++2.0 it uses arduino IDE. I have to turn on and of led through android application. What should I do. Please help me in using AT commands because I have separate GPRS module and Microcontroller (Teensy++2.0).

    Thanking in anticipation

    Zainub Bahar

  13. Pedro Celeste Pedro Celeste

    Hi,

    I have an arduino Uno and a shield 3G + GPRS(http://www.cooking-hacks.com/index.php/documentation/tutorials/arduino-3g-gprs-gsm-gps?utm_source=banner_3g_shield&utm_medium=banner) and I am developing a project, this project goal is to get the coordenates from the Arduino (done) and send that data (Latitude and Longitude) to my web Server (DataBase).

    I follow this example and i think you can help me with this..

    If you can send me a code or some ideias how to complete my project i would really apreciate.

    Best regards

  14. Ankit Joshi Ankit Joshi

    Hello,
    Very nice explanation but i want to know can you perform this same functionality by using webservice through GSM shield.I mean that, i want to operate the led from android mobile wirelessly using GSM shield in arduino without sending sms & voice calls. please reply me as soon as possible.

    Thanks in advance…

  15. santha santha

    hello bros .. my arduino cant work… i dunno … i used port 27,, so .. how i can write script

    void setup() {
    port = new Serial(this, Serial.list()[0], 9600);

    i try [0] .. processing IDE work ane teeling arduino to run led OFF
    but i try to index.html… and clink on… no respon ,,, so please help….

  16. Adam McAllister Adam McAllister

    Ok, so I can get it to turn on and off from my computer…but I hooked it up to another computer and it does not work. How would run turn off the LED from across the world. Do they need to run the Processing program as well.???

  17. Herren Nike Air Max 2011 Mesh-Orange Schwarz Grau Laufschuh bietet maximale D盲mpfung und Flexibilit盲t mit h枚chster Leistung und Stil. Hyperfuse-Obermaterial mit dynamischem Flywire Technologie liefert leichte, flexible Unterst眉tzung, Notched innersleeve und atmungsaktivem Mesh bieten eine nahtlose Komfort. Cushion Zwischensohle und ein full-length Max Air Einheit f眉gen Pl眉sch D盲mpfung f眉r die ultimative Fahrt. Flexkerben f枚rdern einen reibungslosen 脺bergang. Umweltfreundliche Gummiau脽ensohle mit strategisch platzierten BRS 100carbon Gummistollen in der Ferse und Vorfu脽 bietet optimale Traktion. Wt. 10,0 oz.Maximum Sto脽d盲mpfung. Die brutale, repetitive, nach unten gerichtete Kraft des Sports kann verheerend auf den K枚rper anrichten

  18. mahesh ds mahesh ds

    its working thanks a lot explained in a perfect manner

  19. It absolutely was my findings with this that cause me to comprehend that funds and income are an evil within my heart.

    Without doubt, it may serve being an avenue for internet sites to promote their organization.

  20. All of these games plants vs zombies garden warfare download is
    one of the three interesting movies on mobile. From, quiz games like Angry
    Birds game is small but the hordes of ‘nasties’. Being a player
    from moving to the native approach. This game is very
    easy thing you will stay in touch with our web site.
    Even these days, mobile games that involve betting are crowd favorites.

  21. Hello friends, how is all, and what you would like to say concerning this article, in my
    view its truly remarkable designed for me.

  22. The backend part of your company supports these profit centers.
    Then consider yourself one of the few, true internet marketers.

    A internet marketing business, in a nutshell, a business
    that’s designed to run on the internet via a website.

  23. Excellent beat ! I wish to apprentice while you amend your website, how could i subscribe for a blog site?
    The account aided me a acceptable deal. I had been a little bit acquainted
    of this your broadcast offered bright clear concept

  24. lloyd lloyd

    hello guys! I would like to ask if it is working in Windows OS?
    I will appreciate any answers,,

  25. The backend part of your company supports these profit centers.
    As the culture of internet slang grew, it took on new origins from pop culture or video games and television. A internet marketing business, in a nutshell, a business that’s designed to
    run on the internet via a website.

  26. This paragraph is in fact a fastidious one it assists new
    web viewers, who are wishing in favor of blogging.

  27. adi adi

    Dear sindre,
    I am Indonesian, I have tried….
    its working, good job…but could you help me how to control 2 or 4 led?…

  28. Harsha Harsha

    Hello Sir,
    I had done all steps but in processing IDE
    I’m getting TELLING ARDUINO TO TURN LED ON
    but not turning LED ON , I’m using Arduino ATMEGA8.
    Please Help Me

  29. bauer bauer

    I started to write this code everything works fine but when I close proxessing ide it’s stopped working. could anyone tell me why?

  30. Neel Neel

    how to create webpage to upload that three files?

  31. anitha anitha

    hiii,

    how to use this without using processing code.

    • Cynthia Cynthia

      I’m also looking for ways to do it without processing code. Does anybody know if its possible or not?

  32. Hello admin, i found this post on 16 spot in google’s search
    results. I’m sure that your low rankings are caused by hi bounce rate.

    This is very important ranking factor. One of the biggest reason for high bounce rate is due to visitors hitting the back button.
    The higher your bounce rate the further down the search results your posts and pages will
    end up, so having reasonably low bounce rate is important for improving your
    rankings naturally. There is very useful wp plugin which can help
    you. Just search in google for:
    Seyiny’s Bounce Plugin

  33. ondsinet ondsinet

    very nice worked perfectly!

  34. Tanvir Tanvir

    Hi, this works great! Is there a way to to use the processing code with the WiFiShield rather than a serial connection? In other words, so the Arduino doesn’t have to be connected to a PC when being accessed over the internet?

  35. Oldtimer Oldtimer

    Congratulations!
    Great tutorial. In particular for those interested enough to acquire some basic insight into HTML and PHP. I tried it out successfully on my 6 years old and 8 years old grandchildren. A lot easier than teaching my children to program MCS4004 at micro instruction level before there was an assembler available, but as much fun.

    NB.
    There is a module build around ESP8266 that eliminates the need for a computer. Actually, in the case of as simple applications as this one, it makes Arduino obsolete. Now they can run Lego train from the cell phone.

  36. Humana People to People gets the job to advance under-developed
    areas with giving teaching to primary school instructors and artisans,
    helping advocate well being and present knowledge about Aids and then to
    assist with more rising the places farming. Humana People to People represents a variety of different
    plans and duties around poverty-stricken areas of nations globally.
    By way of working together with the regional individuals and their governing administration, they are able to benefit individuals who’re in need of
    assistance through their non-profit aid organizations.
    China is one kind of lots of nations that this non-profit institution visits
    to confront the demanding concerns that they confront now.

    The Humana People to People Motion works with The Federation for
    Associations within the Yunnan province of China. The work started within 2005 and remains throughout
    today. The Humana People to People Association Assignment Department in the Yunnan Area features
    to increase funds so as to execute different jobs in the province in poverty-stricken places.

    A number of plans which Humana People to People tries to take
    to the current area of China involve business schools
    in which they’re able to expand their training, preparing them for work opportunities, giving details of infectious illnesses and many more.

  37. hallo… i got so much error with this. this is the error message :

    sketch_apr25a:4: error: ‘import’ does not name a type
    sketch_apr25a:5: error: ‘Serial’ does not name a type
    sketch_apr25a:16: error: expected constructor, destructor, or type conversion before ‘=’ token
    sketch_apr25a.ino: In function ‘void draw()’:
    sketch_apr25a:36: error: ‘loadStrings’ was not declared in this scope
    sketch_apr25a:37: error: ‘print’ was not declared in this scope
    sketch_apr25a:40: error: ‘println’ was not declared in this scope
    sketch_apr25a:41: error: ‘port’ was not declared in this scope
    sketch_apr25a:45: error: ‘println’ was not declared in this scope
    sketch_apr25a:46: error: ‘port’ was not declared in this scope

    this is my sketch :
    const int ledPin = 13; // the pin that the LED is attached to – change this if you have a separate LED connected to another pin
    int incomingByte; // a variable to read incoming serial data into

    import processing.serial.*;
    Serial port;

    void setup() {
    // initialize serial communication:
    Serial.begin(9600);
    // initialize the LED pin as an output:
    pinMode(ledPin, OUTPUT);
    }

    /* This part must be altered to fit your local settings. The number in brackets after “Serial.list()” is where you declare what COM port your Arduino is connected to.
    If you get error messages, try a different number starting from 0 (e.g. 0, 1, 2, 3…) . */
    port = new Serial(this, Serial.list()[1], 9600); // Open the port that the Arduino board is connected to, at 9600 baud

    void loop() {
    // see if there’s incoming serial data:
    if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it’s a capital H (ASCII 72), turn on the LED:
    if (incomingByte == ‘H’) {
    digitalWrite(ledPin, HIGH);
    }
    // if it’s an L (ASCII 76) turn off the LED:
    if (incomingByte == ‘L’) {
    digitalWrite(ledPin, LOW);
    }
    }
    }

    void draw() {

    String onoroff[] = loadStrings(“http://YOURDOMAIN.COM/LEDstate.txt”); // Insert the location of your .txt file
    print(onoroff[0]); // Prints whatever is in the file (“1” or “0”)

    if (onoroff[0].equals(“1″) == true) {
    println(” – TELLING ARDUINO TO TURN LED ON”);
    port.write(‘H’); // Send “H” over serial to set LED to HIGH

    } else {

    println(” – TELLING ARDUINO TO TURN LED OFF”);
    port.write(‘L’); // Send “L” over serial to set LED to LOW
    }

    delay(7000); // Set your desired interval here, in milliseconds
    }

    the html and php file works fine, but i dont know what i do, i just put together arduino sketch with processing sketch and upload to my arduino. can you help me..?
    thanks before

  38. cn cn

    can i use ethernet shield instead of processing ide?

  39. budi budi

    I am confused how to connect the arduino to use the web tutorial you what pyserial or php_class or web directly associated premises arduino

  40. yulius yulius

    when i using 2 or 3 led, can u explain to me how to using the port..thanks

  41. Alexander Alexander

    Thank you , everything works great ,but how to show the arduino led state on website ?

  42. Daniel Daniel

    hi. good job but i would like to do the same using the ethernet shield. Could you pls provide a sketch sample ? i tried by myself with a wamp server using php and arduino ethernet web client, it’s not working. thanks by adv. Daniel

  43. These waves of vibration arrive at your divine
    door, your energy system, as activators and as reminders. Brain Wave Vibration, Ilchi Lee, 2008, ISBN 9781935127000.
    Think about it, you’re just slowing down the process.

  44. hi sir. i dont know how to upload index.html , led.php and LEDstate.txt to my website. please guide me the process. only this is my problem. i have tested all others. thanks in advance

  45. Jeff Jeff

    I got all this working great. I use this process to initiate a 12vdc pump through my arduino. The only snag I can’t figure out right now is how to set up the code so it doesn’t run in a loop. I am trying to initiate the on button so it is timed after a few seconds; pumps out the required liquid then stops. I am not good at the coding part. If anyone can give me a hand it would be greatly appreciated. Thanks very much for this walkthrough.

  46. Mahesh Mahesh

    nice 100% work well

  47. Sarah Sarah

    A great tutorial – only one problem with this line:

    delay(7000); // Set your desired interval here, in milliseconds

    I would like this to be every 1 second, but it won’t work with less than 10 seconds – delay(10000); Any less than 10 seconds and the LED just comes on and stays on stubbornly refusing to do anything else. Is there a minimum delay or is there a problem with my equipment?

    • Sarah Sarah

      I solved it – the problem only happens with the Mega. Works fine on the Uno 🙂

  48. That means no risky unwanted side effects and it even includes
    a Life Time Warranty to back its powerful fast acting Phase 2 Carb Blocker.
    Water can certainly make you feel full for your whole day.

    We need to tell teens and still have them understand the advantages of healthy living
    generally and different habits to remain fit.

  49. kavindu kavindu

    I’m a beginner to this. I have an error when I compile ”
    exit status 1
    ‘import’ does not name a type”
    Please help me

  50. LowIQ LowIQ

    I’m extremely new at this.
    I’m hoping someone is still active on this thread, however old.
    I am having a lot of trouble getting the arduino.ino working in isolation on my pcduino nano … it is not throwing up any errors. after uploading (locally) all I get is the cpp (command window)pop up and no matter what I type H or L, nothing happens. I cannot pull up the Port Monitor as it just won’t open while the sketch is running … or it doesn’t seem to open?? As I said, no error are thrown.
    Any thoughts please?

  51. Wonderful ѡork! Ƭһɑt iѕ tɦe type οf infoo that aгᥱ meant tо bee shared acrosss tɦе net.
    Disgrace οn tҺᥱ search engines for noա
    not positioning tɦіѕ post ɦigher!
    Ϲome ⲟn ⲟνеr and talk ߋνer ᴡith mmy weeb site .
    Τhank yοu =)

    Αlso visit mʏ web-site: diet tips

  52. Rohan Rohan

    I’m getting same problem as the Gunawan. Getting
    What should i do?sketch_apr25a:4: error: ‘import’ does not name a type
    sketch_apr25a:5: error: ‘Serial’ does not name a type
    sketch_apr25a:16: error: expected constructor, destructor, or type conversion before ‘=’ token
    sketch_apr25a.ino: In function ‘void draw()’:
    sketch_apr25a:36: error: ‘loadStrings’ was not declared in this scope
    sketch_apr25a:37: error: ‘print’ was not declared in this scope
    sketch_apr25a:40: error: ‘println’ was not declared in this scope
    sketch_apr25a:41: error: ‘port’ was not declared in this scope
    sketch_apr25a:45: error: ‘println’ was not declared in this scope
    sketch_apr25a:46: error: ‘port’ was not declared in this scope

    this is my sketch :
    const int ledPin = 13; // the pin that the LED is attached to – change this if you have a separate LED connected to another pin
    int incomingByte; // a variable to read incoming serial data into

    import processing.serial.*;
    Serial port;

    void setup() {
    // initialize serial communication:
    Serial.begin(9600);
    // initialize the LED pin as an output:
    pinMode(ledPin, OUTPUT);
    }

    /* This part must be altered to fit your local settings. The number in brackets after “Serial.list()” is where you declare what COM port your Arduino is connected to.
    If you get error messages, try a different number starting from 0 (e.g. 0, 1, 2, 3…) . */
    port = new Serial(this, Serial.list()[1], 9600); // Open the port that the Arduino board is connected to, at 9600 baud

    void loop() {
    // see if there’s incoming serial data:
    if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it’s a capital H (ASCII 72), turn on the LED:
    if (incomingByte == ‘H’) {
    digitalWrite(ledPin, HIGH);
    }
    // if it’s an L (ASCII 76) turn off the LED:
    if (incomingByte == ‘L’) {
    digitalWrite(ledPin, LOW);
    }
    }
    }

    void draw() {

    String onoroff[] = loadStrings(“http://YOURDOMAIN.COM/LEDstate.txt”); // Insert the location of your .txt file
    print(onoroff[0]); // Prints whatever is in the file (“1″ or “0″)

    if (onoroff[0].equals(“1″) == true) {
    println(” – TELLING ARDUINO TO TURN LED ON”);
    port.write(‘H’); // Send “H” over serial to set LED to HIGH

    } else {

    println(” – TELLING ARDUINO TO TURN LED OFF”);
    port.write(‘L’); // Send “L” over serial to set LED to LOW
    }

    delay(7000); // Set your desired interval here, in milliseconds
    }

    the html and php file works fine

  53. isra isra

    hy i’m have problem in

    print(onoroff[0]); // Prints whatever is in the file (“1” or “0”)

    thats ArrayIndexOutOfBoundsException:0 eror
    please help

  54. yapang yapang

    What is processing app? Where do I write this sketch and how to I upload

  55. Jocelyn Jocelyn

    How do i upload 3 files into website.? could some one guide me on that. Other then that my sketches at Arduino IDE and processing works fine

  56. si si

    At the line:
    import processing.serial.*;
    it give to me the error:
    ‘import’does not name a type

  57. I appreciate the data on your internet site. Thanks a ton!.

  58. matia matia

    hello ..
    I want to ask how to make serial class

  59. Parag Naik Parag Naik

    Nice project. Very well explain. After facing so many errors finally I did. LEDstate.txt file accessible in paid domain only. I tried in 000webhost which is free domain website and facing problem doing the project.
    Overall great project. Thanks for sharing

  60. 出向くことなく当日に融資の申し込みが対応できるキャッシングはモビットが便利。 カードローンを受ける仕方について紹介されています。 モビットは、スマートフォーンからの申し込みでWeb完結ができて限度額も最高800万円で金利3.0%から

  61. If you are interested in topic: earn income online australia visa – you should
    read about Bucksflooder first

  62. Adrian Adrian

    Is the web server a separate machine ?

  63. Ash Ash

    Hello there!

    I am working on a project involving ultrasonic sensors. Can you please help me with how to use the above steps for reading ultrasonic sensor values??

  64. 即日必要な融資は、対応してくれるクレジット会社をしっかりと選択して利用したほうが良いです。業態的に銀行などいろいろあります。これらは利用者の信用状況などで変わってきますが、融資を利用する場合は、口コミ情報などを考慮して決定するべきです。

  65. jymd jymd

    What is this processing ide.Arent there other options in case you are using a different compliler like winavr this print ide is confusing.

  66. Dear baby
    Your article is so helpful for me,i like it,thanks!

  67. davison phiri davison phiri

    True am desperate and i need a big help on thin how to control arduino system fom php to arduino using GPRS and processing programming language

  68. I think that what you posted made a bunch of sense.

    However, think about this, suppose you added a little information?
    I ain’t suggesting your content is not solid., but what if you
    added a post title that grabbed a person’s attention?
    I mean How to remotely enable/disable a LED on your Arduino using PHP and Processing | The project pages is a little vanilla.
    You might look at Yahoo’s home page and see how they create post
    headlines to get viewers to open the links. You might add a video or a pic or two to grab readers interested about everything’ve written.
    Just my opinion, it would make your posts a little bit more interesting.

  69. RJ Ilagan RJ Ilagan

    I’ve tried this code and did all the procedures but the LED won’t lit when i control it using the website, what could be the problem? and one more thing, Can I use Ethernet Shield instead of the Processing IDE?

  70. Everything is very open with a precise clarification of the issues.
    It was really informative. Your site is useful. Many thanks for sharing!

  71. Good way of telling, and fastidious article to get data on the topic of
    my presentation subject, which i am going to convey in school.

  72. Tamunoomie Gogo Tamunoomie Gogo

    Hei, I just stumbled into this tutorial after so many days of trying to get it without the use of processing. Its wonderful and I used that basics to add more devices. Thanks so much. One love

  73. Greaaaaaat!!!!! It works!!!!!

    I have looked at about 10 tutorials and this is the first which works!!!!

  74. I must say it was hard to find your blog in google.
    You write interesting content but you should rank your website higher in search engines.
    If you don’t know how to do it search on youtube: how to rank a website Marcel’s way

  75. My brother suggestyed Imay ike this blog. He was entirely right.
    This post actually made my day. You cann’t consider
    simply how much time I hhad spent for this info!
    Thank you!

  76. jerome jerome

    – TELLING ARDUINO TO TURN LED OFF

    anyone can jelp me what is the meaning of that message. that’s the message i get when i try this tutorial. please help me.

  77. Hi blogger, i must say you have very interesting content here.
    Your page should go viral. You need initial traffic boost only.
    How to get it? Search for: Mertiso’s tips go viral

  78. Hey there, You’ve done an incredible job.
    I’ll definitely digg it and personally recommend to my friends.

    I’m sure they’ll be benefited from this web site.

  79. After looking into a few of the blog posts on your blog,
    I seriously like your way of blogging. I book marked
    it to my bookmark webpage list and will be checking back in the near
    future. Please visit my website as well and let me know your opinion.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.