Distance sensor part1(1)
Distance sensor part1(1)
2024 - 2025
Objectives
Info:
● Speed of sound= 340m/s
● distance= speed / time
● Divide distance by 2
Think & Answer
The Reverse Parking Sensors that are equipped in the car are basically
Ultrasonic Proximity Sensors i.e. they use Ultrasonic Sensors to measure the
distance
SONAR terminals
Trig
Arduino pin LED color
8 Red
9 Red
Arduino pin configuration
LEDs 10 Yellow
11 Yellow
12 Green
13 Green
5 Trig
4 Echo
SONAR
5V 5V
GND GND
3 Buzzer signal
Buzzer
Do you remember??
Top and bottom pins of
bread board are
connected _______
Buzzer
1. Less Than:
2. Greater Than:
3. Equal To:
4. And:
5. Or: Not:
Distance sensor block
Distance sensor block calculate distance in cm. To use this block you need to select trig and echo pins same
as you connected with arduino
Trig
Conditions in programming
Conditions are basic “if, else” logic statements that modify how code is executed. Conditions are a key part
of the decision-making process for computers.
Example
Add operators and distance block here to compare or
check condition
Blocks
Screenshot
● Press Shift + window+s keys together from
keyboard
● Save screenshot on desktop
● Turn-in
Hints:
Follow Pin configuration sheet in slide 9. After completing wiring show to your instructor
for grades
Tu
rn
In
1. Make your code in pictobox App and upload in robot to check.
2. Once you confirm your all tasks are working properly TURN IN for evaluation.
!!
Challenge:2 Buzzer alert system
Whenever distance will get closer, buzzer will start Conditions
giving beep with Red LED.
Task Video
Operators
Hint:
1. Use Conditions
2. Operators Dist
3. Distance sensor
https://drive.google.com/file/d/1gaELeISsCax4g5j8MwCIglyx0teHP
GS2/view?resourcekey
sensor
block
Tu
1. Make your code in pictobox App and upload in robot to check.
rn
2. Once you confirm your all tasks are working properly TURN IN for evaluation.
In
! !
Challenge:3 Make fading LEDs with SONAR
Whenever distance will get closer to the SONAR
sensor, red LEDs will get brighter.
Hint:
1. Use Conditions
2. Operators
3. Distance sensor
block
4. PWM Block