Robotics1d-mBot_Sensors
Robotics1d-mBot_Sensors
mBot Sensors
A robot will have a tough time if it cannot sense the world around it. The mBot has a number of sensors
already onboard which help it respond to things it might encounter as it moves around.
Ultrasonic Sensor
Light Sensors
Infrared Receiver (Communication
between mBots)
Infrared Transmitter (Communication
between mBots)
You will notice that these blocks are all designed to fit where you would put a number in the Scratch
operators and control blocks. This means they can be used directly to control program loops, motor
speeds, and anywhere else where you might use a number.
The sound emitted by the sensor is 40khz. This is too high for us to hear. Our hearing range is typically
between 20Hz and 20kHz. A dog could hear it because a dog can hear up to 45kHz. A bat could also hear
it because they can hear up to 200kHz. Would it confuse a bat?
Setting up a test
To test it we will make use of an extra device we can add to
our mBot. We have some nifty 4-digit displays. If you don't
have a 4-digit display, use the onboard LEDs to light up if
they detect something at a particular distance.
Create a simple program to read the Ultrasonic sensor and display the distance it is measuring. Upload
this and see that it responds to your hand in front of it. Note: We have created the variable called
Distance for holding the reading from the sensor. You can put the distance sensor block directly into the 7-
segment display block if you wish. To do this, just drag and drop the Ultrasonic sensor block into the place
occupied by the number “100” in the image above.
How far away and how close does it detect distances? You may need to point it at a wall to
measure longer distances. How does that match the manufacturer’s specifications?
What is the measurement resolution? Measure how much the sensor reading changes if you move
something towards it by 10cm, 20mm, 10mm, and 5mm?
How big does the object need to be before it can be detected?
Are there shapes it has trouble with?
What is the angle of view over which the mBot can detect things?
Have a go at using these decisions yourself as you walk around the room.
Now try to build an mBot sketch that will do the same. Remember to add in the Wait command to ensure
you have sufficient time for the motors to move enough.
Your Challenge
Is your mBot afraid of the dark? No? Well it - should be. There’s monsters out there.
Use the on-board light sensor to make your mBot speed up to get out of dark places quickly.
This document “Robotics1d – mBot Sensors” by Hamish Trolove is provided under a creative commons
license - Attribution, Share Alike.
http://creativecommons.org/licenses/by-sa/4.0/
www.techmonkeybusiness.com
Robotics 1d – Sensors Page 6 of 6 June 2017