Arduino Sensors!
Jessica
Nametag and Chess Piece Submission
Today’s agenda
What are sensors?
Ultrasonic Sensor
Ultrasonic Sensor
Ultrasonic Sensor
Ultrasonic Sensor
How to find distance?
Distance:
Useful Code for Ultrasonic
pulseIn(anypin, HIGH or LOW): Reads a pulse (either HIGH or LOW) on a pin, returns it in microseconds
delayMicroseconds(#of Sec): delay in microseconds
Ultrasonic Sensor DIY
Fill in the skeleton code
Ultrasonic DIY 2
Imagine if someone breaks into your house in the middle of the night, how would you know?
Make an ultrasonic burglar detecting device that will alarm you and light up a Red LED
MQ 135 Gas Sensor
MQ 135 Gas Sensor
A0: Analog output, connect to any analog pin
D0: Digital output, will be high when threshold output is reached. Control the threshold with pot
Vcc: 5V
GND: Ground
Precaution: MQ 135
MQ 135 Gas Sensor: DIY
Using your knowledge from the previous lectures
Write a simple code that would read the analog outputs from the A0 pin
MQ 135 Gas Sensor: DIY 2
What if there is a natural gas leak at your home? You wouldn’t even know because gas is invisible to the eye.
Make a gas detection device that would light up red, yellow, and green. Each color depicting how hazardous the gas levels are. Red as extremely dangerous, Yellow as mild, and Green as good air.
Temperature Humidity Sensor
Temperature Humidity Sensor
Starting from the left the pins are:
SDA SCL pins on NANO
Connect SDA SCL pins to these nano
pins
Libraries + Temp & Humidity Sensors
Temp & Humidity Sensors: DIY
Call the functions in the library to display temperature and humidity
Code Link