Arduino Internet Controlled Desk Lamp

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(){
Serial.begin(9600);
}

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

char inByte = Serial.read();
if(inByte == ‘1’){
digitalWrite(13,HIGH);
}
else if(inByte == ‘0’){
digitalWrite(13,LOW);
}
}
}

Arduino Internet Controlled Desk Lamp

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 13Connect 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 libraryexample.php = The code
make sure you put the path of your arduino on the following line:
$serial->deviceSet(“/dev/ttyUSB0”);Upload this two files to your server in the same directory.Arduino Internet Controlled Desk Lamp circuit

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top