Motion Triggered Lights




Introduction: Motion Triggered Lights

This guide will show you how to use an FPGA to create a motion sensor triggered light of varying color for as long as there is motion. The levels of red, blue, and green are all controlled by latching a value to each individual color. This project was created by Timmy Nguyen and Ryan Luke for a CPE 133 class final project.

Step 1: Parts

Gather the following parts:

-1 Basys 3 FPGA board

-1 Breadboard

-1 RGB analog LED

-3 npn/n-channel MOSFETs

-1 220 ohm resistor

-1 PIR motion sensor

-multiple jumper cables

Step 2: Program the FPGA Basys 3

For this project, we use Pulse Width Modulation (PWM) to control the brightness and color of an RGB LED, which turns on and off based on the output of a motion detecting PIR sensor. If the sensor detects movement, the LED will turn on for about 4 seconds, which is a function of the sensor.

All files necessary for this project are included in this section.


Clock divider: The Basys 3's onboard clock has a frequency 100 MHz, so we want to bring that frequency down to 10 KHz to better manage it in the counter.

Counter: The counter uses the reduced 10 KHz as an input and counts to 255 when it is enabled by the motion sensor.

3 D Flip Flops: The user will flip any variety of the 8 switches on the board and these flip flops, when enabled by the press of that flip flop's enable button, will latch the value of the switches into the comparator. This latched value will determine the duty cycle, or pulse width, of the output signal that goes to the LED.

3 Comparators: The 8 bit output from the counter goes to each of the comparators separately and is compared with the 8 bit output of the flip flop. If the counter output is less than the latched value from the D Flip Flop, the comparator will output a one-bit High value; if the counter output is greater than the latched value, the comparator will output a one-bit Low value. The comparator then outputs its value into the sensor decoder.

3 Sensor Decoders: The sensor decoder will either output the value of the comparator if there is motion detected by the sensor (1) or low voltage (0) if there is no motion. These outputs go directly to the RGB LED.

After downloading the VHD files:

Once the files are downloaded and placed into a project, synthesize, implement, and write the bitstream for the project. Then, connect the basys 3 board and program the device.

Step 3: Build Circuit on Breadboard

You can follow the schematic and photos create the circuit. The grounds are common throughout the circuit, and additional resistors can be added in series with the mosfets to further dim either the red, blue, or green signals.

Step 4: Connect Components to the Basys 3 Board

You can use the schematic and references in the photos to connect your Basys 3 board to the breadboard.

Step 5: How to Use

You can input a binary value represented by the switches SW0-SW7. Once you have this value, you can press buttons BTN_L (red), BTN_C (blue), and BTN_R (green) to latch that value to the color selected by the button. Meanwhile, the motion sensor will trigger the LED to illuminate with every movement.



    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Microcontroller Contest

      Microcontroller Contest

    We have a be nice policy.
    Please be positive and constructive.