Print Friendly, PDF & Email

Difficulty level: Beginner

Approx reading time:

Components Required:

1. Raspberry Pi 3 model B

2. MicroSD card 8 or 16 GB (Class 4 and above) with Raspbian

3. Windows PC / Linux PC (Tested on Windows 10, Ubuntu 14.04 LTS)

4. Ethernet cable (Category 5 – also called Cat 5)

5. Micro USB cable

6. Breadboard

7. 5 mm LED (your favourite colour)

8. 220 Ohms Resistor (colour code: Red, Red, Brown)

9. Push Button

10. Jumper Wires (Male to Female – Red for Power, Black for Ground, Yellow for GPIO pins Male to Male)

11. 5V 1 Channel Relay Module

Way to go ->

1. Login to your Pi using PuTTy or your Ubuntu terminal.

2. Login to your Pi GUI using VNC server (Linux / Windows).

3. In Python 3 (IDLE), create a new file.

4. The name could be:

5. In the file, write the following code with comments (line starting with “#”) for clear understanding and save (press Cntrl + S on your PC keyboard) the file.

6. Run the code by clicking on Run -> Run Module in the menu bar.

Hardware Connections ->

1. Raspberry Pi 3 GPIO Header.


2. Signal or IP Pin of the Relay module connected to Pin 15 – BOARD notation (GPIO22 – BCM notation). Push Button connected to Pin 40 – BOARD notation (GPIO21 – BCM notation).



Read full tutorial at

Rating widget: