wiki:ControlSystems/Electrical/Training/FallTraining/ProjectSix

Materials Needed

  1. For this project you will need to use the TinkerCAD software as the PIR sensor is not included in the Arduino kit that you have physically.
  1. You will need a PIR sensor, an Arduino, an LED, and a resistor.

Steps

  1. Let’s start with an LED, and connect the anode side of the LED to a resistor, typically with a resistance of 370 to 500 ohms.
  1. Connect the resistor to digital pin 13.
  1. Connect the cathode side of the LED to the GND of the Arduino.
  1. Then, take out a PIR sensor, and connect the left pin (signal pin) to digital pin 2.
  1. Then, connect the middle pin (power pin) to the 5v pin on the Arduino.
  1. Next, connect the right pin (ground pin) to the GND of the Arduino.
  1. Lastly, copy and paste this code into the code section with the blocks option changed to text.
  1. You can then run the simulation, press the PIR sensor, and move the circle around to see what happens.

Code:

const int LED1=13;

const int PIRinput=2;

void setup()

{

pinMode(LED1, OUTPUT);

pinMode(PIRinput,INPUT);

Serial.begin(9600);

}

void loop()

{

Serial.println(digitalRead(PIRinput));

if (digitalRead(PIRinput) == 1){

digitalWrite(LED1,HIGH);

}

if (digitalRead(PIRinput) == 0){

digitalWrite(LED1,LOW);

}

}

Explanation of how it works

  1. The LED is used to indicate when the ball (which represents an object) moves.
  1. The Arduino knows when to turn on the LED because of the PIR sensor that detects motion.
  1. The PIR sensor sends a signal through the signal pin to the Arduino, which makes the Arduino know that the PIR sensor saw something move.
  1. The Arduino then uses that information to turn on the LED.
  1. You will find that many sensors are wired in a similar fashion, with 2 pins dedicated for power (5v and GND/ground), and the other pins are used for transmitting information between the sensor and the Arduino. An example of a sensor that is wired similarly to the PIR sensor is the ultrasonic sensor, which you will get to work with during the electrical meets as a project.
Last modified 4 months ago Last modified on Jan 9, 2021, 3:48:06 PM

Attachments (1)

Download all attachments as: .zip