Categories
TUTORIALS

How to control the rotation of servos by the PIR Sensor and Force Sensitive Resistor

This tutorial explains how to control the rotation of two servos based on the combination of input from a PIR motion sensor and a force sensitive resistor. The scenario set up here ithat when the PIR senses a person nearby and the FSR is not sensing pressure at the same time, the servos will spin 90 degrees from 0, and when the PIR senses a person leaves after showing up nearby, the servos will spin from 90 degrees back to 0.

The components you will need are:
  1. Arduino Uno
  2. Breadboard
  3. Square Force Sensitive Resistor
  4. PIR Motion Sensor
  5. Two Micro Servos
  6. 10k Ohm Resistor
  7. 14 Wires (11 Male to Male wires, 3 Female to Male Wires)
Setting Up the Hardware
  1. Use the 3 Female to Male wires to connect the PIR to the Arduino board, when you put the side of PIR with the 3 pin headers at bottom, from left to right, the three pin headers should be connected to GND, 5V, and Pin 2 respectively.
  2. Connect the left end of the FSR to Pin A0 as well as GND through a 10K Ohm resistor, and connect the right end to 5V.
  3. Connect the two micro servos to the 5V, GND and a pin on Arduino Board respectively. Here we connect the two servos to Pin 9 and Pin 10.

Not clear enough? Here is a schematic diagram and a photo for the wired circuit!

Now let’s check out the code. The key is to define variables to store the readings generated from the PIR and FSR, and use them in the if statement to create different conditions, so that under those conditions you could give the servos different instructions to spin!

Leave a Reply

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