Post Top Ad

Sunday, November 5, 2023

on video Go And Stop Lights|Electrical 14 pin Relay |Electrical Motion sensor Wiring

Go And Stop Lights|Electrical 14 pin Relay|Electrical Motion sensor Wiring

Let's learn to sense movement in a room with a PIR motion sensor and Arduino's digital input. We'll connect up a circuit using a breadboard and use some simple Arduino code to control a single LED. We'll use Tinkercad Circuits to simulate the circuit so you can follow along even without any components, and show you how to build the physical circuit too.


So far you've likely already learned to read a pushbutton with Arduino's digital input, so we'll build on those skills in this lesson. Although the motion sensor may seem complex with its dedicated circuit board, it is configured to send a HIGH or LOW signal in much the same way a pushbutton would.


PIR stands for Passive InfraRed, which describes the technology inside—it passively detects infrared light levels (unlike an infrared camera that may also emit infrared light in order to capture its reflection). The white dome is a lens that expands the IR detector's field of vision. The sensor reports a LOW signal by default, reads the amount of ambient infrared light coming in, and then triggers a HIGH signal for a certain period of time when the light levels change, indicating movement. It can tell you whether or not there is movement in a scene, but cannot detect distance—for that you might consider a type of analog input sensor called an ultrasonic rangefinder.

To optionally build the physical circuit, gather up your Arduino Uno board, USB cable, solderless breadboard, an LED, resistor (any value from 100-1K), PIR motion sensor, and breadboard wires.



You can follow along virtually using Tinkercad Circuits. You can even view this lesson from within Tinkercad (free login required)! Explore the sample circuit and build your own right next to it. Tinkercad Circuits is a free browser-based program that lets you build and simulate circuits. It's perfect for learning, teaching, and prototyping.

Explore the sample circuit here in the embedded circuit below by starting the simulation and clicking on the round motion sensor. This will activate a highlighted area in front of the sensor with a circle “object” inside. You may need to resize the view if the circle is off the screen. Click and drag the "object" circle in front of the sensor to represent movement. The LED will turn on for a short time when movement is detected.


The free-wired version of this circuit is pictured above. If needed, take a moment to refresh your breadboard knowledge. You could load up a new Tinkercad Circuits window and build your own version of this circuit along side the sample.

Identify the PIR motion sensor, LED, resistor, and wires connected to the Arduino.


Drag an Arduino Uno and breadboard from the components panel to the workplane.


Connect breadboard power (+) and ground (-) rails to Arduino 5V and ground (GND), respectively, by clicking to create wires.


Extend power and ground rails to their respective buses on the opposite edge of the breadboard by creating a red wire between both power buses and a black wire between both ground buses.


Plug the LED into two different breadboard rows so that the cathode (negative, shorter leg) connects to one leg of a resistor (anywhere from 100-1K ohms is fine). The resistor can go in either orientation because resistors aren't polarized, unlike LEDs, which must be connected in a certain way to function.


Connect other resistor leg to ground.


Wire up the LED anode (positive, longer leg) to Arduino pin 13.

Drag a PIR motion sensor from the components panel to your breadboard, so its legs plug into three different rows.


Connect the center leg to ground.


Create a wire connecting the leftmost leg to Arduino analog pin A0.

Let's use the Blocks coding interface to listen to the PIR motion sensor, then make a decision to light up an LED based on the sensor's state: activated or not activated.



We’ll store the state of our PIR motion sensor to our variable sensorState. Click on the Input block category, drag out the “read digital pin” block, and place it into the “set” block after the word “to”.


Since our sensor is connected to the Arduino on Pin 2, change the dropdown of the “read digital pin” block to 2. Now your blocks should read “set sensorState to read digital pin 2” which stores a digital reading of the sensor pin into our sensorState variable!


Click the Control category and drag out an “if then” block.

Configure it to evaluate whether sensorState is equal to HIGH using a Math comparator block. Drag out the Math comparator block into your if statement to check whether our variable sensorState is equal to HIGH.


We want to turn our LED on if the sensor is activated - otherwise, we want our LED to be off. Under the Output block category,find the “set built-in LED to HIGH” block. Try adding two of these blocks to our if statement so that the LED will only be on when the sensor is activated. set built-in LED should be HIGH when the sensor state is HIGH - otherwise, set built-in LED should be LOW.


 

Go And Stop Lights|Electrical 14 pin Relay|Electrical Motion sensor Wiring

Let's learn to sense movement in a room with a PIR motion sensor and Arduino's digital input. We'll connect up a circuit using a breadboard and use some simple Arduino code to control a single LED. We'll use Tinkercad Circuits to simulate the circuit so you can follow along even without any components, and show you how to build the physical circuit too.


So far you've likely already learned to read a pushbutton with Arduino's digital input, so we'll build on those skills in this lesson. Although the motion sensor may seem complex with its dedicated circuit board, it is configured to send a HIGH or LOW signal in much the same way a pushbutton would.


PIR stands for Passive InfraRed, which describes the technology inside—it passively detects infrared light levels (unlike an infrared camera that may also emit infrared light in order to capture its reflection). The white dome is a lens that expands the IR detector's field of vision. The sensor reports a LOW signal by default, reads the amount of ambient infrared light coming in, and then triggers a HIGH signal for a certain period of time when the light levels change, indicating movement. It can tell you whether or not there is movement in a scene, but cannot detect distance—for that you might consider a type of analog input sensor called an ultrasonic rangefinder.

To optionally build the physical circuit, gather up your Arduino Uno board, USB cable, solderless breadboard, an LED, resistor (any value from 100-1K), PIR motion sensor, and breadboard wires.



You can follow along virtually using Tinkercad Circuits. You can even view this lesson from within Tinkercad (free login required)! Explore the sample circuit and build your own right next to it. Tinkercad Circuits is a free browser-based program that lets you build and simulate circuits. It's perfect for learning, teaching, and prototyping.

Explore the sample circuit here in the embedded circuit below by starting the simulation and clicking on the round motion sensor. This will activate a highlighted area in front of the sensor with a circle “object” inside. You may need to resize the view if the circle is off the screen. Click and drag the "object" circle in front of the sensor to represent movement. The LED will turn on for a short time when movement is detected.


The free-wired version of this circuit is pictured above. If needed, take a moment to refresh your breadboard knowledge. You could load up a new Tinkercad Circuits window and build your own version of this circuit along side the sample.

Identify the PIR motion sensor, LED, resistor, and wires connected to the Arduino.


Drag an Arduino Uno and breadboard from the components panel to the workplane.


Connect breadboard power (+) and ground (-) rails to Arduino 5V and ground (GND), respectively, by clicking to create wires.


Extend power and ground rails to their respective buses on the opposite edge of the breadboard by creating a red wire between both power buses and a black wire between both ground buses.


Plug the LED into two different breadboard rows so that the cathode (negative, shorter leg) connects to one leg of a resistor (anywhere from 100-1K ohms is fine). The resistor can go in either orientation because resistors aren't polarized, unlike LEDs, which must be connected in a certain way to function.


Connect other resistor leg to ground.


Wire up the LED anode (positive, longer leg) to Arduino pin 13.

Drag a PIR motion sensor from the components panel to your breadboard, so its legs plug into three different rows.


Connect the center leg to ground.


Create a wire connecting the leftmost leg to Arduino analog pin A0.

Let's use the Blocks coding interface to listen to the PIR motion sensor, then make a decision to light up an LED based on the sensor's state: activated or not activated.



We’ll store the state of our PIR motion sensor to our variable sensorState. Click on the Input block category, drag out the “read digital pin” block, and place it into the “set” block after the word “to”.


Since our sensor is connected to the Arduino on Pin 2, change the dropdown of the “read digital pin” block to 2. Now your blocks should read “set sensorState to read digital pin 2” which stores a digital reading of the sensor pin into our sensorState variable!


Click the Control category and drag out an “if then” block.

Configure it to evaluate whether sensorState is equal to HIGH using a Math comparator block. Drag out the Math comparator block into your if statement to check whether our variable sensorState is equal to HIGH.


We want to turn our LED on if the sensor is activated - otherwise, we want our LED to be off. Under the Output block category,find the “set built-in LED to HIGH” block. Try adding two of these blocks to our if statement so that the LED will only be on when the sensor is activated. set built-in LED should be HIGH when the sensor state is HIGH - otherwise, set built-in LED should be LOW.


 

No comments:

Post a Comment

Post Top Ad

Pages