Learning LEGO MINDSTORMS EV3 by 2015
Author:2015
Language: eng
Format: epub
Publisher: Packt Publishing
Infrared versus Ultrasonic
We are going to start out with a simple program and will gradually add complexity to it. If you are using the Ultrasonic Sensor, it should be plugged into port 4, and this program is on the top line. If you are using the IR sensor, it should be plugged into port 1 and this program is at the bottom line. In this program, the robot moves forward until the Wait block tells it to stop 25 units from a wall or other barrier. You will find that the Ultrasonic Sensor can be set to stop in units of inches or centimeters. The Ultrasonic Sensor emits high-frequency sound waves (above the range of human hearing) and measures the time delay between the emission of the sound waves and when the reflection off an object is measured by the sensor.
In everyday conditions, we can assume that the speed of sound is constant, and thus the Ultrasonic Sensor can give precise distance measurements to the nearest centimeter. As mentioned in Chapter 4, Sensors and Control, using presence we could use the Ultrasonic Sensor to detect other robots or a loud sound. In other programming languages, you could even use the Ultrasonic Sensor to transmit data between two robots. The IR sensor emits infrared light and has an IR-sensitive camera that measures the reflected light. The sensor reading does not give exact distance units because the strength of the signal depends on environmental factors such as the reflectivity of the surface. What the IR sensor loses in precision in proximity measurements, it makes up for in the fact that you can use it to track on the IR beacon, which is a source of infrared light. In other programming languages, you could actually use the IR sensor to track on sources of infrared light other than the beacon (such as humans or animals).
In the following screenshot, we have a simple program that will tell the robot to stop a given distance from a barrier using a Wait for the sensor block. The program on the top of the screenshot uses the Ultrasonic Sensor, and the program on the bottom of the screenshot uses the IR sensor. You should only use the program for the sensor you are using. If you are downloading and executing the program from the Packt Publishing website, you should delete the program that you do not need.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12645)
Hello! Python by Anthony Briggs(9948)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9825)
The Mikado Method by Ola Ellnestam Daniel Brolund(9814)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(9714)
Dependency Injection in .NET by Mark Seemann(9369)
Hit Refresh by Satya Nadella(8855)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8334)
The Kubernetes Operator Framework Book by Michael Dame(7942)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7811)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7791)
Exploring Deepfakes by Bryan Lyon and Matt Tora(7730)
Grails in Action by Glen Smith Peter Ledbrook(7722)
Practical Computer Architecture with Python and ARM by Alan Clements(7674)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(7641)
Robo-Advisor with Python by Aki Ranin(7626)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7591)
Building Low Latency Applications with C++ by Sourav Ghosh(7516)
Svelte with Test-Driven Development by Daniel Irvine(7494)
