3.Light Searching

Welcome to another exciting tutorial with your Bocobot Car! This time, we're going to add the ability to detect and chase light sources. Imagine the fun you could have leading your car around with just a flashlight!

 

 

Installing the Light Dependent Resistor (LDR)

The key to our car's new abilities lies in a light dependent resistor (LDR). This clever little component is sensitive to light, and we're going to use it to make your car react to light sources in its environment.

 

To start, connect the LDR to Grove port 6 on your Robo Pico. If you're unsure how to do this, don't worry. The connection diagram below shows the minimum connection requirement for this lesson.

Setting Up the Software

We'll need a new script from our Github repository to give your car its light searching abilities. If you haven't yet downloaded the files or need to re-download them, you can do so here.

 

Next, copy the content of the '03_Light_Searching.py' file and paste it into the 'code.py' file on your Raspberry Pi Pico W. 

 

This '03_Light_Searching.py' script is what makes the magic happen. It tells your Bocobot Car to use the LDR to detect any light source in front of it. If it spots a light source, your car will cleverly increase its speed to chase it.
 

อุปกรณ์ฮาร์ดแวร์