0% found this document useful (0 votes)
8 views9 pages

Lab 6

The document provides detailed instructions for using three types of sensors with Arduino: the TCRT5000 IR sensor for detecting color and distance, the PIR SR505 motion sensor for detecting movement, and the HC-SR04 ultrasonic sensor for measuring distance using sonar. Each section includes a description, features, pin definitions, material preparation, connection steps, and sample source code. Additionally, links to further tutorials are provided for each sensor.

Uploaded by

trantiendat1679
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

Lab 6

The document provides detailed instructions for using three types of sensors with Arduino: the TCRT5000 IR sensor for detecting color and distance, the PIR SR505 motion sensor for detecting movement, and the HC-SR04 ultrasonic sensor for measuring distance using sonar. Each section includes a description, features, pin definitions, material preparation, connection steps, and sample source code. Additionally, links to further tutorials are provided for each sensor.

Uploaded by

trantiendat1679
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Lab 6:

Student ID:
Full in name:
Group:

6-1: Using IR Sensor (TCRT 5000) With Arduino


Description:
This IR reflective sensor utilizes a TCRT5000 to detect color and distance. It emits IR
and then detects if it receives the echo. This sensor is often used in line following
robots, auto data logging on utility meters, because this module can sense if a surface
is white or black. The measuring distance range from 1mm to 8mm, and the central point
is about 2.5mm. There is also an on-board potentiometer to adjust the sensitivity. The
infrared diode will emitting the infrared continuously when the module connect to the
power, when the emitted infrared light has not been reflected or the strength is not big
enough,the module will in the off state, at this time, D0 output logic HIGH and the signal
indicate LED off.
Features:
- Supply Voltage: 3.3V~5V
- Detect distance: 1mm-8mm
- Digital Outputs LOW when objects detected
- On-board indicator LED to show the results
- On-board potentiometer to adjust the sensitivity
- On-board LM393 chip
Step 1: Pin Definition

Step 2: Material Preparation & Step 3: Pin Connection


Step 4: Sample Source Code
const int pinIRd = 8;
const int pinIRa = A0;
const int pinLED = 9;
int IRvalueA = 0;
int IRvalueD = 0;
void setup()
{
Serial.begin(9600);
pinMode(pinIRd,INPUT);
pinMode(pinIRa,INPUT);
pinMode(pinLED,OUTPUT);
}
void loop()
{
Serial.print("Analog Reading=");
Serial.print(IRvalueA);
Serial.print("\t Digital Reading=");
Serial.println(IRvalueD);
delay(1000);

IRvalueA = analogRead(pinIRa);
IRvalueD = digitalRead(pinIRd);
}
Result
Link: How to Use TCRT5000 IR Sensor Module With Arduino UNO : 7 Steps (with
Pictures) - Instructables

6.2 Motion Sensor PIR SR505 Mini Arduino


Description:
Motion sensor alarms allow individuals and businesses to keep their homes and job
sites safe from intruders. These devices work by using light, microwaves, vibrations,
and other methods to detect changes in the environment. This can include the breaking
of a light or laser beam, movement, or additional heat indicative of a human in the area
of the sensor, as well as additional sensing methods.here i made simple one using
arduino and pir sensor ,every one can make it as well cause its quite simple you need
those stuff for your project
Features:
Wide range of operating voltage
Minimum size
Repeatable trigger
Low power consumption
Automatic control
Trigger: reusable trigger by default
Sensing distance: 3 meters
Sensor lens dimensions: diameter- 10mm
Operating voltage range: +4.5V to +20V
Maximum operating voltage: +20V
Operating temperature range: -20ºC to 80ºC
Quiescent current: <60µA
Induction angle: <100 degrees cone angle
Step 1: Pin Definition

HC-SR505 is a three pin device as shown in figure and the function of each pin is stated
below.
Pin Name Function

- Ground This pin is grounded for the operation of the module

S Signal Output The module provides output signal at this pin

+ Positive power supply A positive voltage of minimum +5V is supplied at this pin for the device
Step 2: Material Preparation & Step 3: Pin Connection

Step 4: Sample
Source Code
/* PIR sensor tester */
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600); }
void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) { // we have just turned on
Serial.println("Motion detected!"); // We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){ // we have just turned of
Serial.println("Motion ended!"); // We only want to print on the output change, not state
pirState = LOW; } } }
Result
Link: https://mschoeffler.com/2017/08/30/tutorial-how-to-use-the-hc-sr505-pir-sensor-
with-the-arduino/

6.3: Ultrasonic Sensor HC-SR04 with Arduino


Description:
The HC-SR04 ultrasonic sensor uses sonar to determine the distance to an object. This
sensor reads from 2cm to 400cm (0.8inch to 157inch) with an accuracy of 0.3cm
(0.1inches), which is good for most hobbyist projects. In addition, this particular module
comes with ultrasonic transmitter and receiver modules.
Features:
Power Supply :+5V DC
Quiescent Current : <2mA
Working Current: 15mA
Effectual Angle: <15°
Ranging Distance : 2cm – 400 cm/1″ – 13ft
Resolution : 0.3 cm
Measuring Angle: 30 degree
Trigger Input Pulse width: 10uS TTL pulse
Echo Output Signal: TTL pulse proportional to the distance range
Dimension: 45mm x 20mm x 15mm
Step 1: Pin Definition
The pinout of the HC-SR04 Ultrasonic Sensor.
VCC Powers the sensor (5V)

Trig Trigger Input Pin

Echo Echo Output Pin

GND Common GND

Step 2: Material Preparation & Step 3: Pin Connection

Step 4: Sample Source Code


/*
* created by Rui Santos, https://randomnerdtutorials.com
*
* Complete Guide for Ultrasonic Sensor HC-SR04
*
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) - Pin11
Echo: Echo (OUTPUT) - Pin 12
GND: GND
*/
int trigPin = 11; // Trigger
int echoPin = 12; // Echo
long duration, cm, inches;
void setup() {
//Serial Port begin
Serial.begin (9600);
//Define inputs and outputs
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// The sensor is triggered by a HIGH pulse of 10 or more microseconds. // Give a short
LOW pulse beforehand to ensure a clean HIGH pulse: digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the signal from the sensor: a HIGH pulse whose // duration is the time (in
microseconds) from the sending // of the ping to the reception of its echo off of an
object. pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
// Convert the time into a distance
cm = (duration/2) / 29.1; // Divide by 29.1 or multiply by 0.0343 inches = (duration/2) /
74; // Divide by 74 or multiply by 0.0135
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();

delay(250);
}
Result
Link:
https://arduinogetstarted.com/tutorials/arduino-ultrasonic-sensor

You might also like