Using Raspberry Pi to drive motion sensor and turn on LED



In this project, we will use a Raspberry drive motion sensor  and LED. When motion is detected, motion sensor will send signal to Raspberry Pi GPIO port and then turn on LED. We will use C and wiringPi libary to handle GPIO signals.

Circuit Graph:


Software Installation:

1)Install git core(if you have already installed git core, please skip this step). Please run following shell command in Pi terminal:

sudo apt-get install git-core

sudo apt-get update

sudo apt-get upgrade

2)Install wiringPi libary(if you have installed wiringPi, please skip this step). Please run following command in Pi terminal:

git clone git://


cd wiringPi



3)Download/compile blink.c and run the program as following:




gcc -Wall -o blink blink.c -lwiringPi

sudo ./blink

Result as following:When you use your hand to block photoresistor light, the LED will turn on.
Ctrl+c killer the program
Posted in Raspberry Pi Project

Leave a Reply

WordPress spam blocked by CleanTalk.