(cid:53)(cid:46)(cid:47)(cid:38)(cid:38)(cid:41)(cid:35)(cid:41)(cid:33)(cid:44)(cid:0) GUIDES Chapter 1 The Sonar Sensor I f you’re reading this book you probably already know about some of the incredible things you can do with Lego Mindstorms You may even have built some Mindstorms robots yourself Hopefully you know what the different parts do how to make a basic program and how to use the EV3 programmable brick If not you should start by reading Unofficial Guides Mindstorms Level 1 Then come back to this book once you’re ready Adding sensors to your projects will greatly expand what you can do with Mindstorms 4
MINDSTORMS Level 2 The focus of this book will be learning how to use sensors in your Mindstorms projects Sensors collect information about their environment They send this information to the EV3 programmable brick The EV3 responds to the information in different ways depending on how it is programmed For example you might create a program that allows a robot to detect and avoid obstacles There are two different Mindstorms EV3 kits available for purchase The retail kit comes with a color sensor and a touch sensor The education kit has those sensors too However it also includes an ultrasonic sensor and a gyro sensor The retail kit has an infrared sensor and a remote control that can be used with it This book covers the color sensor touch sensor ultrasonic sensor and infrared sensor The gyro sensor is more complex than the others If you want to learn more about it check out the other books in this series Let’s start by learning how to use the ultrasonic sensor This is the one that looks like it has round red eyes It is commonly referred to as the sonar sensor 5
(cid:53)(cid:46)(cid:47)(cid:38)(cid:38)(cid:41)(cid:35)(cid:41)(cid:33)(cid:44)(cid:0) GUIDES This is because it works a lot like the sonar ability used by bats A bat can send out special sound waves You can’t hear them but they bounce off nearby objects and return to the bat The bat then knows how far away different objects are how fast they are moving and which direction they are heading in The Mindstorms sonar sensor uses a similar technique to determine the distance of objects The sonar sensor has two round red eyes 6
MINDSTORMS Level 2 You can learn a little about the sonar sensor before you use it to build a robot Attach a sonar sensor to one of the four input ports on the EV3 The input ports are labeled 1 2 3 and 4 It doesn’t matter which one you use right now On the EV3 select the icon with six small circles then choose the Port View option Now choose the port number of the attached sonar sensor You should see the readings of the sensor measured in centimeters Pick up the sonar sensor and move it around See what types of readings you get You should notice that the number goes up the farther the sensor is from an object Moving the sensor closer should make the number go down Try to get the number as high and low as possible In theory the lowest number that you should be able to read is 0 However you will find that it is very difficult to get a reading of 0 The smallest you can detect will likely be around 4 centimeters The largest reading you can get is 255 centimeters The EV3 can also display sensor readings in inches To try this out hit the middle button on the EV3 while still viewing the port It will display three options US-DIST-CM US-DIST-IN and US-Listen Select US-DIST-IN Check the minimum and maximum values that you can read in inches Again you should 7