Max:Bot 3: Sense the light

0 3192 Easy

In previous chapters, since Max:Bot is, like an alive creature with eyes, able to recognize and avoid obstacles, what else can we explore about his sensory system?

projectImage

You will be surprised that Max:Bot can even sense the brightness of light. In this chapter, we will work together to learn how to achieve this.


🔸 Goals


1. How to use the light sensor?

2. How to use the digital display module?

3. Diagram aided programming


🔸 Digital modules

projectImage

💜 3.1 Adventure to brightness


When in surroundings with strong lights, people used to instinctively narrow their eyes for protection. Whereas being in surroundings with poor lights, they are not able to distinguish objects. Here come the questions: it is what that influences the light brightness. How the colors of lights influence its brightness?

projectImage

To make above clear, we should ask Max:Bot for help. As the saying goes: learn to walk before you run. So we will need first to use Micro:bit to transfer the brightness into output values.


🔸 Key information

projectImage

🔸 Program


(1) Start a new program and name it as “adventure to brightness”.

(2) Find the “show number” function from “Basic” and place it into the “forever” loop. The initial number is “0”.

projectImage

(3) As we have mentioned above that the “show number” function can be used to show the number that has been read by the “light level” function. So, in this step, we need first to find the “light level” function from the “Input” in the function area, and then place it to the “show number” function. Place them into the “forever” loop.

projectImage

(4) Download the program to Max:Bot . The detected brightness will be showed immediately on the 5x5 LED matrix of Micro:bit, then we can see the brightness with our own eyes.

projectImage
projectImage

🔸 Exercise


There are different rooms with different lights in your house, why not go and detect their brightness? You can record them in the table below.

projectImage

💜 3.2 The moth robot


Have you ever seen, at night, hundreds of moths flew against the streetlights? That is because moth is a kind of phototactic insect. Sounds very interesting, right? As have learnt the principle about how can Max:Bot sense the brightness, we can now apply it into a moth robot.

projectImage
projectImage

🔸 Program


(1) Start a new program and name it as “the moth robot”

(2) When the brightness reaches a certain range of value, the moth robot will go forward to the light. Whereas stay and rotate if the value is not reached. Below diagram can provide assistance to your program.

projectImage

(3) In this part, the operator “=” will be used to judge if the brightness reaches the set value or not. And the “servo write” function is used to make the robot go forward or rotate. The “if else” function here is used to judge when should it go forward and when to stay and rotate. By putting all the functions listed above together, we will have the final program as below:

projectImage

💡 Please note: the value of brightness should neither be too large nor too small, it should be kept in a reasonable range.

projectImage

If the value is too large, the moth robot will not go forward till a relatively strong light is given.

If the value is too small, the moth robot will then not likely to stop moving forward.

So you have to think twice and set a reasonable value.


(4) Download the final program to Max:Bot . You can now play a light sensing game with this moth robot.


🔸 Exercise


Let’s hold a race for the moth robot player.

You can invite your friends to join the race. Each of you will use the same electric torch to guide the moth robot move forward. The winner goes to the person that completes a lap in the shortest time. The starting line stands a red flag.

projectImage

Tips: Maintain its speed within a reasonable range holds the key to success.

License
All Rights
Reserved
licensBg
0