Introduction: Control Your Room Lights Using Your Computer

In this Instructable, i have made a system by which one can control your room lights or fan using your PC or mac.

To explain it better, i will categorise the complete intructable into two parts

1) Hardware section (includes arduino, relay and a power supply)

2) Software section (designing GUI using Processing software)

Step 1: Parts Needed

Below is the list of parts needed to build this instructable

1) Arduino (nano) or any other Arduino

2) Relay module

3) 12V Power supply

4) Breadboard

5) Connecting Wires

Step 2: Connections

This was time to connect all the parts.

The 12V power supply was used to power up the relay module.

To trigger the relay module, you can connect any digital pin of arduino to the input pin of relay module.

I have used pin 13 of arduino to trigger the relay.

As the arduino is powered up from usb port of your system, so don't forget to common the Ground of arduino to Ground of power supply.

For testing the load a 220V bulb was connected to relay module.

By this time the connection was complete.

Step 3: Software Section

There are 2 parts in software section.

1) Arduino's code

2) GUI using Processing software.

Both codes are attached for reference.

The arduino coding is quite simple, arduino is reading serial data from USB and turn on or off the relay module accordingly.

The processing IDE is also very similar to arduino IDE. Arduino library was imported in processing and a rectangle was drawn using rect function, whenever mouse is pressed in that rectangular area, a serial data is sent to arduino, which in result turn ON or OFF the relay.

Step 4: Testing the Project

This was time to test the project, and the result was quite good, it worked like a charm.

As it can be seen from the images that when mouse is clicked the bulb is turning ON and when again it is clicked the bulb is turned off.

For more details, you can refer to video link attached in the intro section.