## Makes (Lego) Sense to Me!

David Luders on Flickr

Sensors give robots the senses humans have.

In order to navigate through the world, people must take information from outside of our bodies and process it within. How do we do this? For the most part, we use our five basic senses: touch, smell, taste, sight, and sound. Without our senses we would bump into walls, fall down stairwells, eat food that our bodies cannot process, and have no way to communicate with one another.

Robots are made of synthetic materials that do not have any built in senses. So how can robots navigate through their environments? Fortunately, there are hundreds, if not thousands, of sensors that we can buy for our robots to help them detect where they are, what’s around them, and allow them to communicate with each other as well as with us humans.

### EV3 Sensors

The Legos EV3 robotics kit comes with three separate sensors as well as sensors built into the servo motors. We can use EV3 legos to build all sorts of robots. Depending on what we need our robot to accomplish, we can choose what sensors to include on it.

A fun beginning robotic project is to build a robot that follows a given path. If we know the path in advance we can program our robot to travel forward a certain distance, turn a certain number of degrees and so on. But what if we want to generalize the process so that we can place our robot on any path and be confident that the robot will not stray?

#### Color Sensor

Every color reflects a certain amount of light, and the EV3 color sensor takes in that light, converts it to a number, and use it to ensure the robot never strays off a given path. For example, we could draw any path in black ink on a white sheet of paper and use EV3 legos to build any style robot we like. So long as we attach the color sensor on part of the robot such that it is always within approximately one centimeter of the paper, it will read in the amount of light that is reflected below it.

When the color sensor is above the black path, it will read in the amount of light reflected by black, and convert that amount into a number. If the path curves but the robot travels on straight ahead, the color sensor will end up over the white surface, and read in the amount of light reflected by white. We can program our robot to move a certain way if it sees black, and another way if it sees white. In this way we can guarantee that our robot always stays on the black path.

When we lift the color sensor more than a couple centimeters from a surface, we notice the amount of light it reads in drops to almost zero. Can you think of how to use this drop in value to program a robot to back up and turn around when it reaches a precipice such as the edge of a table or a stair case?

#### Infrared Sensor

An infrared sensor is a bit like a color sensor in that it also detects light. However, it emits its own, infrared, light and measures the distance between itself and an obstacle by detecting what percent of its infrared light gets reflected back. If little or none of its light is reflected back then the robot might want to continue forging ahead. On the other hand, if too high a percent of its light comes back to it, the robot is likely near an obstacle and may need to reverse directions to avoid collision.

#### Touch Sensor

The EV3 touch sensor is basically a button. It can be programmed so that when it is not pushed the robot behaves a certain way, and when it is pushed the robot does something different. By attaching a bumper to the touch sensor, we can expand the amount of surface used to trigger the button. If the bumper touches a wall or other obstacle in front of it, it changes state from “zero” to “one”. This allows us to program our robot to continue moving forward when the touch sensor reads “zero” and to make a noise or back up and turn around when it reads “one”.

Though the home edition of the EV3 robot set includes three sensors, both a gyro sensor and an ultrasonic sensor are available for purchase separately, or as part of the EV3 Education set. The gyroscopic sensor is used to detect rotational acceleration.

In other words, it calculates the angle between itself and the ground to tell the robot how quickly it is falling or tipping. In turn, this information can be used to program a robot to continually determine the angle between itself and the ground and correct itself if it is off balance. Outside of the EV3 set, gyroscopic sensors are critical for keeping contraptions such as the Segway balanced, as well as for building accurate navigation systems.

Ultrasonic sensors are another real world device with an EV3 version. They the idea behind them is similar to that behind the infrared sensor, except an ultrasonic sensor emits a sound waves instead of light. The sensor measures the time it takes for its high-frequency sound waves to bounce back to it, and based on that time, calculates the distance between itself and an obstacle.

Outside of EV3 robotics, ultrasonic sensors are used in a wide range of applications from determining the distance between a crop and boom on agricultural machinery, to measuring proximity between cars in vehicles such as the Tesla.

#### LEGO Mindstorms EV3

https://www.lego.com/en-us/mindstorms

#### Accelerometer vs. Gyroscope: What’s the Difference?

https://www.livescience.com/40103-accelerometer-vs-gyroscope.html

#### Robotsquare EV3 Robots

http://robotsquare.com/category/robots/ev3/

#### Brick Marketplace

Our Favorite MINDSTORMS EV3 Projects With Instructions
http://blog.brickmarketplace.com/2015/07/mindstorms-ev3-projects-instructions.html

#### EV3DEV

A project that expands on EV3 programming by allowing it to boot a Linux-based operating system able to use much broader programming languages and devices
http://www.ev3dev.org/

### Also In The October 2017 Issue

Building and creating your tools with the Minecraft toolbox helps you survive the game.

Sensors give robots the senses humans have.

30+ ideas for all age holiday gifts, from books to apps to board games to VR and more.

There might be a reason that too-real robot and video game character creeps you out.

You computer mouse cursor finally gets a cat to chase it.

Create turtles with Python, the programming language.

Use micro:bit to water your plants!

Studying satellite photographs shows a lot about what happens in the world.

There are a number of strategies teachers (plus parents and students) can take to learn programming.

Pigpen ciphers uses alien-like symbols to hide secret messages.

This project uses conductive thread to create a glove to activates your phone.

The repl.it website and React are one way to create mobile apps.

Software programming does neat things with language, in this case, mixing capital letters.

This Scratch game has lots of ways you can customize the game play. No cats were harmed in the making of this article either.

Links from the bottom of all the October 2017 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about computer science, software programming, and technology for October 2017.