Skip to Content
Arduino Cookbook, 3rd Edition
book

Arduino Cookbook, 3rd Edition

by Michael Margolis, Brian Jepson, Nicholas Robert Weldin
April 2020
Intermediate to advanced
795 pages
17h 43m
English
O'Reilly Media, Inc.
Book available
Content preview from Arduino Cookbook, 3rd Edition

Getting Input from Sensors

6.0 Introduction

Getting and using input from sensors enables Arduino to respond to or report on the world around it. This is one of the most common tasks you will encounter. This chapter provides simple and practical recipes for how to use the most popular input devices and sensors. Wiring diagrams show how to connect and power the devices, and code examples demonstrate how to use data derived from the sensors.

Sensors respond to input from the physical world and convert this into an electrical signal that Arduino can read on an input pin. The nature of the electrical signal provided by a sensor depends on the kind of sensor and how much information it needs to transmit. Some sensors (such as photoresistors and Piezo knock sensors) are constructed from a substance that alters its electrical properties in response to physical change. Others are sophisticated electronic modules that use their own microcontroller to process information before passing a signal on for the Arduino.

Sensors use the following methods to provide information:

Digital on/off

Some devices, such as the tilt sensor in Recipe 6.2 and the motion sensor in Recipe 6.4, simply switch a voltage on and off. These can be treated like the switch recipes shown in Chapter 5.

Analog

Other sensors provide an analog signal (a voltage that is proportional to what is being sensed, such as temperature or light level). The recipes for detecting light (Recipe 6.3), temperature (Recipe 6.9), and ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Arduino for Arduinians

Arduino for Arduinians

John Boxall
Getting Started With Arduino, 4th Edition

Getting Started With Arduino, 4th Edition

Massimo Banzi, Michael Shiloh

Publisher Resources

ISBN: 9781491903513Errata PageSupplemental Content