Light sensors are devices that detect and measure the intensity of light. They play a crucial role in robotics by enabling robots to perceive and react to their environment. In this lesson, you'll learn about the basics of light sensors and how they're employed in robotics.
Light sensors work by converting light energy into electrical signals. The most common type of light sensor is the photoresistor, which changes its resistance based on the amount of light it receives. When the light intensity increases, the resistance decreases, and vice versa. This change in resistance can be measured and used to determine the light levels in the environment.
Light sensors have multiple applications in robotics, such as:
The microbit has a built-in light sensor that can be accessed through its LED display. Although it's not as accurate as a dedicated light sensor, it's still useful for basic light sensing applications.
Here's an example of how to use the microbit's built-in light sensor to display the light level on the LED matrix:
basic.showNumber(input.lightLevel())