This tutorial teaches how to read values from sensors in the mBlock IDE. There are also tutorials which specifically focus on how to use the Makeblock sensors, for example the light sensor, the ultrasonic sensor and the line follower sensor.
The easiest way to find out what value a sensor is giving is to have a Sprite (panda by default) “say” it. In the “Looks” Scripts, there is a “say” block:
Of course, if we ask the panda to say “Hello!”, the panda is going to say “Hello!”. Fortunately, we can replace this text with the name of whatever sensor we wish to read. This is for the ultrasonic sensor:
The line follower sensor:
And the on-board light sensor:
For the plug-in sensors, you have to make sure the port selected is the same port as the port you have plugged your sensor into.
Now, you can click this block and it will tell you the value of the sensor. To make it continually update, you can put this block in a forever loop:
- Can you find a way to display the values of different sensors at the same time?
- Can you find out the range of possible values for all the sensors?
Construct Your Dreams!