Labs / Bipes + MicroPython

7 Sensors: Enable Programs to "Perceive the World"

Author: Li Zisheng Β· Source: FreakStudio open documentation Β· License: CC BY 4.0

Contents

In our previous lessons, we have already enabled the program to perform calculations, make judgments, and control lights and buzzers. However, if a program always runs strictly following fixed instructions, it still cannot "perceive the world" in essence.

In this chapter, we are going to do something really important: πŸ‘‰ endow the program with the ability to "perceive the world".

Just imagine: without you pressing any buttons, the development board can "see" that it's dark and turn on the light automatically, "sense" that the temperature is too high and trigger an alarm automatically, and "detect" harmful gases and send an immediate alert β€” this is the magic of sensors! They can convert those "invisible and intangible" environmental information such as light, temperature, flame, human proximity, and gas changes into digital signals that the development board can understand, turning programs from "passive execution" into "active perception" to truly realize "intelligent response".

A sensor building block acts as the "interpreter" connecting the development board to the outside world: it helps the development board "read" the environmental data collected by the sensor, and then enables you to perform corresponding actions through program logic (such as conditional judgment and delay).

1. What is "perception"?

Think about how we ourselves perceive the world:

These judgments do not arise out of nowhere; instead, they stem from sensation.

In electronic systems, sensors function as the "sensory organs":

πŸ“Œ Understand sensors in one sentence:

Sensors are what enable a program to "know what is happening outside".

2. Different sensors have different sensing methods.

In this chapter, you will be introduced to a wide variety of sensors, but they do not all "sense" in the same way.

Some sensors function more like a switch:

Some sensors function more like a :

There are also some sensors that are inherently very "smart":

πŸ“Œ Therefore, the sensors introduced in this chapter are not arranged in a random manner; instead, they are presented progressively from the simple to the complex and from the intuitive to the abstract in a step-by-step fashion.

3. What will you learn in this chapter?

After completing the study of this chapter, you will be able to:

More importantly, you will find that:

Programs no longer merely execute commands, but instead operate in a cycle of "observe – orient – act".

4. Description of the Content Structure of This Chapter

In this chapter, we will follow the pace of "from simple to complex, from manual reading to direct block-based invocation" to get to know 12 extremely practical sensors one by one:

Each sensor will work in coordination with:

You’ll find that once you equip a development board with its β€œsensory organs”, you can create so many cool and amazing tricks with it!

✨ Chapter Introductory Reflection

Before we start, please take a moment to think about this:

  • If a system has no sensors at all, what kinds of "intelligent responses" can it make?
  • If you were to design a "smart classroom", what information would you most want it to be able to perceive?

With these questions in mind, let’s dive into the world of sensors together πŸš€