1)Objective:

This project will show you how to use Arduin to drive HC-SR501 infrared motion sensor and detect human motion.

2)Parts and Devices

1 x Arduino UNO

1 x HC-SR501 infrared motion sensor

1 x USB cable

1 x 2-channel relay

1 x RED LED

1 x BLue LED

1 x Breadboard

Jumper wires

3)Circuit graph

HC-SR501_Ralay_bb

4)sample code link

down load motion sensor relay sample code

5)Result

When human is moving close to motion sensor, relay channel one will open and channel 2 will close, RED LED will turn on and blue LED will turn off. When human is moving away from sensor, relay channel 1 will close and channel 2 will open. Red LED will turn off and Blue LED will turn on. Picture as following:

IMG_20160815_142542 IMG_20160815_142602