.Read The Ridiculously Simple Guide to MacBook Pro With Touch Bar: A Practical Guide to Getting Started With the Next Generation of MacBook Pro and MacOS Mojave (Version 10.14) (Ridiculously Simple Tech) Download ebook. Download and install the new pre-release programming software for LEGO MINDSTORMS EV3 to your Apple Computer with macOS 10.14 Mojave or above. This pre-release has limited functionality, but you can install and connect to your programmable brick and download programs to your five Hero robots. To use Lego's Ultrasonic Sensor with the EV3 Home set, an extra component must be added to the EV3 Home set's editor. This tutorial shows you how to do that. No worries, EV3 sensor multiplexer is designed for that purpose. Connect upto 3 sensors on single sensor port; Works with NXT or EV3. Connect any of the LEGO EV3 sensors. High speed polling architecture for high performance robots. EV3SensorMux does not work with third party sensors. Supported Sensors: EV3 Ultrasonic Sensor; EV3 Gyro Sensor. There are three different ways to connect to your EV3 Brick in Mindstorms: USB, Bluetooth and Wi-Fi. Connecting with a USB cable is the easiest and simplest but a wireless connections allows you to be untethered from your brick. Bluetooth will allow your Brick close range communication with a device or other EV3 bricks and Wi-Fi will give you wider communication range.

Implementing the next logic for aligning to the border when we approach the border from the right.

  • #164
  • 13 Nov 2015
  • 6:17
  • LEGO MINDSTORMS
  • EV3, Ultrasonic Sensor, Programming
  • K.Mitov

You can approach the border/wall from the right or from the left. In the previous video we finished with doing it from he left. Now we continue with extending the program to be able to approach the wall from both sides. But it is not always that easy.

Previous video tutorials:

Try to align Ultrasonic program

English

Previously we did a program that was aligning the robot to the border using 2 LEGO Mindstorms ultrasonic sensors and it was working like this. In this video we'll also introduce the other logic for aligning the robot when we approach from the right. How can we do this? Let's see in the program.

Using the same logic here as in the previous program won't work because here in this program, that is working only when we are approaching the border from the left, this program works, because we are waiting for the ultrasonic sensor on port 4 to detect the border first. If the border is detected by the other sensor, the sensor on port 1, this program won't work.

So I'll just remove this blocks, like this, and we'll implement another logic. The other logic goes like this. We can use a switch block. In some of the previous programs we've used switch blocks and today we are again using a switch block. The goal of this switch block is to detect which of the sensors sees the border first. We'll add a loop and in this loop we would constantly check. What are we checking. We are checking the sensor on port 4 and we get the distance in inches. Let's say 4 inches. We are comparing for value less than or equal to 4 inches. When the sensor detects a value of less than or equal to 4 inches it will execute the blocks in this part of the switch and when the value is greater than 4 inches it will execute this part of the block.

What we want to do is the moment we detect something, that is the border, we want to stop the whole robot. The first sensor on port 4 has detected something, in this case the border, that is less than or equal to 4 inches and we stop the whole robot. Let's download and see if this program works.

Position the robot, like this, run the program. The robot moves and the moment the sensor on port 4 detects the border we stop. Now we must do the same thing for the other sensor.

If, for example, the sensor on port 4 is not detecting the wall we should check weather the sensor on port 1 is detecting the wall. It is again an ultrasonic sensor, compare, distance in inches. We check if this sensor detects something less than or equal to 4 inches.

Now you see that this 2 switch blocks look kind of ugly currently and what we should do is change them to flat view, tabbed view. Now it would take less space on the screen and because of that it is more convenient to look at it. We have the following cases. Just to make sure that you can see it. If the sensor on port 4 detects the border, we stop. If the sensor on port 4 is not detecting the border, we check the one on port 1 and if the sensor on port 1 detects the border we again stop.

We run this program. Running the program again from the previous position. We run the program and the robot stops. Then we run the program from the other position and the robot stops.

What we basically have is a program that stops near the border no matter if we run from the left or from the right of the border.

Now what's left is to add the logic for aligning to the border no matter if we run from the left or from the right. It will be the same logic that we've used in the previous video but we'll continue with this logic in the next video.

This writeup is intended for use with the EV3. For the NXT version, see Sensors.

The experimental objective of this lab is to design various Mindstorms programs that use rotation, light, touch, and ultrasonic sensors.

These exercises will build a foundation of experience with sensors programming that can be used with the semester-long design project.

Mindstorms Program

Before we can learn to use sensors, we must become familiar with the EV3. Remember that the Mindstorms program is a compiler: a program used to make other programs. Just as a compiler is used when creating and debugging a C++ program, Mindstorms similarly compiles programs for the EV3. The Mindstorms interface is graphic; a text compiler like those used for C++ is not. However, the principle is very much the same. Actions are taken based upon circumstances set by the programmer.

The EV3 houses all the programming instructions that control the movement of your robot. Once you have created your program in Mindstorms, it is uploaded to the EV3. The EV3 then dictates the robot's motion. If your robot does not do what you intended, you must rewrite the program in Mindstorms and upload the corrected version to the EV3.

  • Lab PC
  • Mindstorms Software
  • USB Cable
  • EV3 Unit

Rotation Sensor

For this portion of the lab, you will learn how to use the rotation sensor in the motor to determine the distanced your robot moved.

  1. Click on the orange tab and select the Loop block. Connect it to the Start block.
  2. Click on the yellow tab and select the motor rotation block. Insert it into the loop block.
  3. Click on the green tab and select the display block. Insert it into the loop block.
  4. Click on the image button on the display block. Change it to Pixels.
  5. On the top right corner of the display block, click on MINDSTORMS and change it to Wired.
  6. Click on the measurement button on the motor rotation block and change the measurement to rotations.
  7. Wire the Motor Rotation block to the Display block by clicking and dragging the mouse from the tab on the motor rotation block to connect to the text input on the display block.

With the program now completed, upload it to your EV3 and run the program. Turn the motor that is connected to port A and look at the display. You should see numbers on the display that correspond to the number of times you've turned the motor.

Example for Rotation Sensor

Suppose you wrote a program that had your robot's motors move forward for 3 seconds.

Let's say you want to add the code that we previously made so that you can read the number of rotations that your robot made while it's moving. In order to do that, you'll need to create a new sequence beam.

  1. Start by clicking on orange tab and selecting the start block. Insert it anywhere on the screen.
  2. Create the program previously made on the start block
Ultrasonic sensor lego ev3

Example #2 for Rotation Sensor

Suppose we wanted to create a program that displayed the number of rotations, but instead of having it loop forever, it would stop measuring the number of rotations once you've rotated it three times.

  1. Create the program shown below
  2. Click on the infinite button in the loop block and change it to rotations.
  3. Set the threshold value to 3 and make sure that the comparison type is greater than.

When you run this program, you should be able to see the number of rotations on the EV3's display. If you make more than 3 rotations on the motor, the program should end.

Ultrasonic Sensor

For this portion of the lab, you will learn how to use the ultrasonic sensor in order to determine the distance between the robot and an object.

The code for obtaining a distance reading and displaying it on the EV3's screen is almost exactly the same as the code for the rotation sensor. The only difference is that instead of the rotation sensor block, you must use the ultrasonic sensor block

Example for Ultrasonic Sensor

Suppose we wanted to write a program in which our EV3 would show a happy face if the Ultrasonic Sensor detected a distance greater than 40 in, and show a sad face if the Ultrasonic Sensor detected a distance less than 40 in.

  1. To start off this program, we'll first need the switch block, which can found by clicking on the orange tab
  2. On the switch block, click on the button and configure it to compare the distance in inches
  3. In the configuration panel, change the compare type to greater than, and set the threshold value to 40 in.
  4. Place a display block into each of the two cases beams in the switch block
  5. Configure each display block so that it shows the correct image. Remember that the EV3 should display happy face when the distance sensed by the Ultrasonic Sensor is greater than 40 in and show a sad face when the distance is less than 40 in.
  6. Place the entire switch block into a loop block.

Example #2 for Ultrasonic Sensor

Sensor

Now suppose we wanted to add an additional case to the program where the EV3 would display a caution sign when the Ultrasonic Sensor senses a distance less than 40 in but greater than 30 in, and display a sad face when the distance sensed is less than 30. In this situation, one switch case won't be enough, as the program will only check to see if the value obtained is greater than or less than one specific number. To overcome this problem, we'll need an additional switch case inside of the switch case we already have.

In this program, when the distanced sensed is greater than 40, it will display a happy face, just like before. When the distance sensed is less than 40, it will check to see if it's greater than or less than 30, and show the appropriate image based on that.

Task

Create a program in which your robot maintains a distance of 8 and 20 in from the wall. In other words, your robot should move away from the wall if the ultrasonic sensor senses a distance less than 8 in and moves towards the wall if the ultrasonic sensor senses a distance greater than 20 in.

Touch Sensor

For this portion of the lab, you will learn how to use the touch sensor to control the actions of your robot based whether the touch sensor has been pressed or bumped.

Example for Touch Sensor

Suppose you wanted to create a program in which your robot would move when the touch sensor is pressed, and would stop when the touch sensor was released.

Ev3
  1. Insert a switch block and have it set to the touch sensor
  2. Insert a move block into each of the sequence beams. Configure one motor block to move continuously and set the other motor block to stop
  3. Place the switch block into a loop block

Light Sensor

For this portion of the lab, you will learn how to use the light sensor in order to determine the light intensity of the sensor's reflected light. You will also learn how to use the light sensor to follow a line.

The program for obtaining the light intensity and displaying it on the EV3's screen is the same as that of the rotation sensor and the ultrasonic sensor, except you need to use the light sensor block.

Download Ultrasonic Sensor Ev3 Macbook Programmer

Line Following Code Using One Light Sensor

The code for following a line using one light sensor is shown below.

This block of code alternates between the left and right motor of the robot, depending on whether the light sensor sees the line. For example, let us assume that motor A is the left motor and motor C is the right motor. Thus, when the light sensor sees the line, the right motor (motor C) stops while the left motor (motor A) starts turning. This causes the robot to turn away from the line while moving forward. Also, when the light sensor doesn't see the line, the left motor stops while the right motor starts turning. This causes the robot to turn towards the line while moving forwards.

Line Following Code Using Two Light Sensors

The code for following a line using two light sensors is shown below.

This block of code alternates between turning the left and right motor of the robot, depending on which light sensor sees the line. First, let us assume that motor A is the left motor and motor C is the right motor. Also, we'll assume that light sensor 1 is the left light sensor and light sensor 2 is the right light sensor. Thus, when the left light sensor sees the line, but the right line sensor doesn't, the left motor stops while the right motor starts moving. If the right light sensor sees the line, but the left light sensor doesn't see the line, the right motor stops while the left motor starts moving. If neither light sensor see the line, then both motors start turning.

For positioning, the robot should be placed such that the light sensors are in between the line.

Tasks

Course 1

Create a program in which your robot travels from point A to point C in a clockwise manner, then rotates 180 degrees and finally returns to point A.

Course 2

Apple macbook pro software download. Create a program in which your robot travels from point A to point H in a clockwise manner, rotates 180 degrees, and travels to point C.

A zip file including the following programs needs to be submitted to the EG Website. If you don't know how to make a zip file, read the page How to Compress Your Files in the Instructional Presentations section of this manual.

Lab Report

There is no lab report for this lab.

Team PowerPoint Presentation

Ev3 Ultrasonic Sensor Tutorial

There is no presentation for this lab.

Laboratory Experiments
Write-ups
1A1B233 Virtual4A55 Virtual677 Virtual88 Virtual977 Virtual1111 Virtual
Presentations
1A&1B233 Virtual4A55 Virtual677 Virtual88 Virtual91010 Virtual1111 Virtual
Archived
DNA (Prelab ¦ PPT) • Sensors PrelabMagLev (PPT) • MicrophoneDesign Failure
Back to Main Page

Download Ultrasonic Sensor Ev3

Retrieved from 'http://manual.eg.poly.edu/index.php?title=Sensors_(EV3)&oldid=5756'