Step 1: Components & Things You Need

  • Resistance – 100 ohm
  • Led – Any color
  • MOC3021 Optoisolator
  • Triac – BT136
  • AC Two pin sockets
  • Raspberry Pi 3 Model B or any other variant.
  • Keyboard and Mouse
  • HDMI cable

Step 2: Design a PCB

You have to design the PCB from: or you can use any other PCB design software to build your PCB. Then you have to generate Gerber File.

I have design my PCB and get it done by JLCPCB.

JLCPCB is a Company where you will get 10 no. of 2 layer PCB for just $2 & Big Discount on First order :
If you want to get my circuit then contact me at


Step 3: Connection Diagram

You have to connect all the components as shown in above diagram. Instead of Sw1 in diagram you have to use MOC3021 IC 6th and 4th terminal in series And on primary side pin 1 and 2 goes to your raspberry pi pin 18 and Gnd.

Next just load Raspbian operating system in raspberry pi and follow this steps.

The Code:
You are now ready to write some code to switch the Lamp on. Turn on your Pi and connect HDMI cable with TV.

Create a new text file “”

Type Following Code in file. Once you have typed all the code and checked it, save and then click on Run button from menu.


import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False)


print “LED on”



print “LED off”


Video Tutorial

Free WordPress Themes, Free Android Games