0% found this document useful (0 votes)
28 views

Arduino 7 - Sensors: Mr. Mcbrien Tej2O

This document discusses sensors and ultrasonic distance detection using an Arduino. It begins by noting there are many types of sensors that can detect things like fire, heat, water, light and more. Sensors convert situations into electrical signals that code can interpret. The document then discusses ultrasonic distance detection in particular, noting sound travels at 340 m/s and the sensor detects distance by timing how long it takes a sound pulse to return. It provides activities to output distance measurements to a serial monitor and trigger LEDs at certain distance thresholds. It notes ultrasonic sensors are prone to noise but filtering algorithms can help remove unlikely measurements.

Uploaded by

mike simson
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Arduino 7 - Sensors: Mr. Mcbrien Tej2O

This document discusses sensors and ultrasonic distance detection using an Arduino. It begins by noting there are many types of sensors that can detect things like fire, heat, water, light and more. Sensors convert situations into electrical signals that code can interpret. The document then discusses ultrasonic distance detection in particular, noting sound travels at 340 m/s and the sensor detects distance by timing how long it takes a sound pulse to return. It provides activities to output distance measurements to a serial monitor and trigger LEDs at certain distance thresholds. It notes ultrasonic sensors are prone to noise but filtering algorithms can help remove unlikely measurements.

Uploaded by

mike simson
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Arduino 7 - Sensors

Mr. McBrien
TEJ2O
Yesterday

 Motors
Today

 Sensors
 Measuring distance
Sensors
 There are MANY different kinds:
 Fire

 Heat

 Water

 Light

 MORE!

 Sensors convert a situation into an electrical signal

It’s our job to write code that interprets the


electrical signal.
What makes a good sensor?

 Cheap, lightweight, tough, waterproof, etc.


A good sensor is sensitive to a given physical input
 To be useful, it has to be insensitive to other physical
inputs. (specific)

What happens if a sensor only works in low humidity?


Coping with Imperfect Sensors

 What do you do when a sensor isn’t perfect?


 Ans_1: enhance your design
 Ans_2: use cases!
 Ans_3: make lemonade.

If your oxygen sensor only works when it’s level,


maybe it’d make a better tilt sensor for a robot.
A Bit about Sound
 Sound waves are a simple vibration in air
 Solid objects reflect these waves – echoes
 Generating sound and then detecting the reflection is
called “echolocation”.
 Echolocation has been used by many different systems
Ultrasonic Distance
 Sound travels at 340 m/s in air.
 The time taken for a pulse to return to the detector can
give us the distance.
Activity 1 – Output Distance to
Serial Monitor

 Wire the ultrasonic detector to the breadboard.


 Connect to the Arduino.
 Review the reference code
 Output the distance, in cm, to the serial monitor.
 Use a ruler to check the accuracy of the detection.
Include this report with your submitted code.
Activity 2 – Decisions Based on Distance

 Add LEDs to your ultrasonic breadboard.


 Light 1 LED when the object gets within 1 m.
 Light 2 LEDs when the object gets within 20 cm.
Sensors and “Noise” Key
Pitfall!
 Remember the specificity requirement?
 Allsensors give output NOT associated with the
target stimulus.
 Random: “high frequency noise”
 Systematic: “low frequency noise” - baseline

The ultrasonic detector is prone to random


spikes in distance.
Eliminating High Frequency Noise
P4 Need!
 High frequency noise is often mathematically removed.
 We can also remove the noise logically – is your backing up
car likely to move 2 meters in 0.01 seconds?
 Signal averaging and spike rejection are two ways to
exclude unlikely data points from your decision-making
process.

After your device is ready for testing, you can


design an algorithm to remove HF noise.
Key Points
 Like with most sensors, ultrasonic distance detection is based
on a mathematical operation on the electrical output from
the device.
 Distance is particularly important to robotics.
 Noise is a common problem with sensors, but can be
addressed in software.
Homework

 Refine your code.


 Don’t forget comments!
References

 http
://www.instructables.com/id/Simple-Arduin
o-and-HC-SR04-Example/

You might also like