This is a little project I did to control my desk lamp over the internet.

Step 1: What You'll need

A linux web-server with PHP, an arduino, a relay and some other components.

Step 2: Upload your code to the arduino

Upload the following code to your arduino:

void setup(){

void loop()
  if (Serial.available() > 0) {

    char inByte = Serial.read();
    if(inByte == '1'){
    else if(inByte == '0'){

Step 3: The circuit

Connect everything as shown in the image.
Connect the base of the transistor to the pin used in the code I used pin 13

Connect your light bulb in series with switching contacts of the relay.

And connect your arduino to your server.

Step 4: The webpage

php_serial.class.php = Serial library

example.php = The code
make sure you put the path of your arduino on the following line:

Upload this two files to your server in the same directory.

Step 5: Test it

Make sure your permissions are right
go to your terminal and type: ls -l /dev/ttyUSB0
then you'll should get a response like:  crw-rw-rw- 1 root .............
otherwise you have to set the permissions type: chmod 666 /dev/ttyUSB0

Browse to the example page.

Normally you should be able to control your lights.

About This Instructable


117 favorites


Bio: Hello, I'm Bruce. I'm a student in Belgium. I have a wide variety of interests: electronics, computers, technology, ... In my spare time I ... More »
More by geo bruce: High Speed Photography Arduino Internet Controlled Desk Lamp Nyan Cat on Arduino
Add instructable to: