Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Practical Arduino Robotics

You're reading from  Practical Arduino Robotics

Product type Book
Published in Mar 2023
Publisher Packt
ISBN-13 9781804613177
Pages 334 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Lukas Kaul Lukas Kaul
Profile icon Lukas Kaul

Table of Contents (21) Chapters

Preface Part 1: Selecting the Right Components for Your Robots
Chapter 1: Introducing Robotics and the Arduino Ecosystem Chapter 2: Making Robots Perceive the World with Sensors Chapter 3: Making Your Robot Move and Interact with the World with Actuators Chapter 4: Selecting the Right Arduino Board for Your Project Part 2: Writing Effective and Reliable Robot Programs for Arduino
Chapter 5: Getting Started with Robot Programming Chapter 6: Understanding Object-Oriented Programming and Creating Arduino Libraries Chapter 7: Testing and Debugging with the Arduino IDE Part 3: Building the Hardware, Electronics, and UI of Your Robot
Chapter 8: Exploring Mechanical Design and the 3D Printing Toolchain Chapter 9: Designing the Power System of Your Robot Chapter 10: Working with Displays, LEDs, and Sound Chapter 11: Adding Wireless Interfaces to Your Robot Part 4: Advanced Example Projects to Put Your Robotic Skills into Action
Chapter 12: Building an Advanced Line-Following Robot Using a Camera Chapter 13: Building a Self-Balancing, Radio-Controlled Telepresence Robot Chapter 14: Wrapping Up, Next Steps, and a Look Ahead Index Other Books You May Enjoy

Making Robots Perceive the World with Sensors

Every robot needs sensors to perceive its environment, and sometimes to monitor itself. This chapter introduces some essential background of sensor technology in general and presents specific sensors that are the most useful, most accessible, and easiest to integrate into an Arduino-based robot. We will take a look at how your Arduino can communicate with these different sensor types, and we will go through code examples that show how to use the most common interfaces (GPIO, analog, I2C, Serial Peripheral Interface (SPI), and Serial).

This chapter is divided into the following sections:

  • Understanding common sensor characteristics
  • Commonly used sensor types for Arduino robots
  • Common sensor interfaces and code examples

Technical requirements

We will use a variety of sensors in this chapter to exemplify the various interfaces. You do not need to buy each of these sensors to get the most out of this chapter. However, it will be helpful if you reproduce at least the potentiometer example. For this, you will need your Arduino Uno again, an analog potentiometer (rotary or linear), and three cables to connect the two.

Understanding common sensor characteristics

The task of a sensor is to turn a feature of the physical world that our robot cares about, for example, the ambient temperature, into an electrical signal that the Arduino can read via any of the interfaces that we will discuss later in this chapter. To select a suitable sensor, we need to be sure that it can at least theoretically meet the requirements of our application. There are many characteristics for any given sensor, but in practice, it can be hard to know at the start of a DIY robotics project what exact requirements really matter. It can sometimes be difficult to find the exact technical details of a sensor. That being said, the two characteristics that you should always consider when selecting a sensor for your robots are the sensor’s measurement range and resolution.

The measurement range tells us what the minimum and maximum values of the physical quantity that our sensor measures are. A distance sensor, for example...

Commonly used sensor types for Arduino robots

There are so many distinct types of robots that it is impossible to make a general recommendation for the right sensors to choose for your project. But it is useful to know what sensors are out there so you know what you can choose from. We will look at a list of sensor types in this section, and then revisit some of them later in the chapter as examples for several types of interfaces. Most of the parts that we will call sensors are technically sensor modules. The actual sensor is only one part of it, and there are additional parts such as voltage regulators, signal conditioning circuitry, and Analog-to-Digital Converters (ADCs). It is not uncommon for all these parts to be integrated into a single chip.

Switches and buttons

Arguably the simplest sensor types are switches and buttons that either open or close a contact when pressed, and do the opposite when released. Simple as they are, they might be all that your first mobile robot...

Common sensor interfaces and code examples

Now that we have gotten to know a few types of very useful sensors for Arduino robots, we need to understand how to talk to them. As we mentioned in Chapter 1, Introducing Robotics and the Arduino Ecosystem, an Arduino board such as the Arduino Uno has many different types of interfaces and the Arduino IDE provides us with the software building blocks to use these interfaces very easily. This section will walk you through the most relevant interfaces and show example code for each of them that communicates with a specific sensor.

GPIO – great for simple sensors

General-Purpose Input/Output (GPIO) includes all the digital pins of our Arduino. For the purpose of this section, we will only use its input functionality. To interface with sensors, it can be used in two different modes (with and without an internal pull-up resistor), and some GPIOs can serve as external interrupt triggers to capture inputs with very high timing accuracy...

Summary

In this chapter, we got to know several useful types of sensors and the interfaces that an Arduino board can use to communicate with them. Needless to say that there is a lot more to write about each sensor type and the intricacies of each interface. But you now know the fundamentals and essential terms of the subject, which gives you a solid foundation from which you can dive deeper into any topic that is relevant to your next project.

After having learned a lot about the possibilities of adding sensing capabilities to your robot, the next chapter will be dedicated to motors that enable your robot to move.

Further reading

You can find more information about the Arduino libraries and the components we used in this chapter in the following resources:

lock icon The rest of the chapter is locked
You have been reading a chapter from
Practical Arduino Robotics
Published in: Mar 2023 Publisher: Packt ISBN-13: 9781804613177
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}