In this lesson will teach our robot how to follow a source of light. Enjoy!
Preparations
- You will need the Light following robot.
- Connect the Light following robot with LOFI Blocks.
Programming
The idea behind the program is to make the robot move in the direction of the strongest light the light sensors can detect. So if the light will be coming from the right side of the robot, more light will come to the light sensor on robot’s right side, and more power should go to the right motor to make the robot turn right. The same applies to the left side and in the situation when both light sensors will detect a similar amount of light.
We will only need two blocks:
Now, let’s make the movement of the motors dependent on the reading from light sensors:
If you play the program in this form, the robot will easily follow a strong source of light, like a flashlight. However, to make the robot react to lower light, we need to amplify the signals transferred to the motors. For this, we need a number block and a multiply block (both can be found in NUMBERS category). Next, we’ll just multiply block INPUT1 and INPUT2 by some small number, 1.5 or 2, and then put these connected blocks in the TURN blocks. Like this:
Our light following program is completed! Good job!