mBot |
|
Your mBot is equipped with its very own light sensor. This means that it can sense the degree of light that is present in the room.
You need to program your mBot so that it automatically spins around in circles whenever the lights in the room are off. However, it needs to immediately stop spinning as soon as the lights are turned back on.
To get started, add the following code to your project:
You need to program your mBot so that it automatically spins around in circles whenever the lights in the room are off. However, it needs to immediately stop spinning as soon as the lights are turned back on.
To get started, add the following code to your project:
Then click the Green Flag to start the program. The value picked up by the light sensor will now constantly be displayed on the screen. This will give you an idea of what the light sensor value is when the mBot is in a bright classroom. The higher the number, the more light it is detecting.
Now put the mBot in a darker area (like in a cupboard or in the same place with some lights off). You should see that the value picked up by the light sensor changes when you do this. It should be lower now.
You can now get rid of the purple 'say' block. The only purpose of that block was to tell us the value of the sensor when the lights are on and off. Now that we have those numbers figured out, we don't need that particular block anymore.
You should now be ready to make the mBot spin in the dark and freeze in the light.
Try to figure this out on your own first. Take your time. Don't be in a rush. If you REALLY need help, let Mr. Locke know and he might show you a hint.
Now put the mBot in a darker area (like in a cupboard or in the same place with some lights off). You should see that the value picked up by the light sensor changes when you do this. It should be lower now.
You can now get rid of the purple 'say' block. The only purpose of that block was to tell us the value of the sensor when the lights are on and off. Now that we have those numbers figured out, we don't need that particular block anymore.
You should now be ready to make the mBot spin in the dark and freeze in the light.
Try to figure this out on your own first. Take your time. Don't be in a rush. If you REALLY need help, let Mr. Locke know and he might show you a hint.