Categories
TUTORIALS

Using Force Sensitive Resistor (FSR) to identify pedestrians or bikes by blinking RGB LED

Introduction

In this tutorial, we will show you how to use a Square Force Sensitive Resistor (FSR) to detect when a pedestrian or a bike is passing by. The FSR will trigger an RGB LED to light up for a few seconds, providing a sense of safety for neighborhoods. This system can be easily set up by placing the FSR on the sidewalk, particularly in areas where vacant lots pose a higher safety risk. Moreover, this setup can also help conserve energy by only turning on the lights when someone passes by.

Parts list

  • Force Sensitive Resistor (FSR) (In this tutorial, we use Square Force-Sensitive Resistor (FSR) Alpha MF02A-N-221-A01 From Adafruit, Product ID: 1075)
  • Arduino board
  • Breadboard
  • Wires
  • RGB LED
  • Three 220 ohm resistors
  • One 10k ohm resistor

Optional: Battery 

Workflow

  1. Connect one end of the FSR to the 5V power source, the other to Analog A0, and the ground. Make sure to use a 10k ohm resistor between the ground wire.
  2. Connect the longest lead of the RGB LED to the ground. Connect the blue lead to pin 11, the green lead to pin 10, and the red lead to pin 9. Remember to use a 220-ohm resistor for each wire to prevent burning out the LED.
  3. That’s all for the wiring! Ensure that the code matches the pins you have just connected. You can also adjust the color of the LED to your preference.
  4. In the following code, the LED will turn white when a pedestrian passes by (which is detected by a value of around 1,000). If it’s a bike passing by (detected by a value of around 2,000), the LED will turn blue. Be sure to test the values you want to detect and adjust the threshold and reaction color to your liking.

Circuit Diagram

Wiring Diagram

Well done! It will look like this!

Wiring Image

Code

Let’s test it!

The RGB LED lights up when a pedestrian walks by (detected by a similar value to pressing with fingers)

Congratulations! You now know how to use an FSR to trigger an RGB LED. If you’re interested in seeing how we apply this to projects, please check out our project on Healthy Blocks.

Reference

1. ELEGOO Lessons 2 and 4

2. Adafruit FSR Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *