Robotics‎ > ‎

Lego EV3 - Programming

Gyro on EV3
Lego EV3
Welcome to Lego EV3 - great way to move into creating robots instead of just using them. When you first log on you are greeted with this screen. We are going to start with the basics so create a new project (File - New Project, or Ctrl-N).
 

Move it

1st off we are going to try to get our robot moving.  On the project screen you have Programming Palettes at the bottom of the screen.  They are organized by colour.  Green blocks are action blocks.  The fourth one in is the move tank block (hold your mouse over it to see what it is).
Move Tank
When you drag this onto the screen and connect it to the play icon you see there are options like below:
Move Tank options
This says that B + C are the motors that it assumes are connected to the EV3 brick.  It is really important to ensure that the left motor is plugged securely into port B and the right motor is plugged into port C - by having the motors run for 3 seconds you can click the Download and run button (bottom right of the screen) to see if it works.
Tip: always have your robot off the ground when you run a program for the first time so you can see if it is going to do what you expect.
Left motor plugged in
Bottom right of the screen

React to your Environment

In the TLDSB Robofair our playing surface is black with white paint around the edges.  If you build your robot and use a colour sensor pointing to the ground you can use this information to stop your robot before it goes over the edge.
Sensors plug into the numbered ports on the EV3 brick (for this we are plugging into port 3).  The Port view shows you not only what you are connected to but what the value it is receiving:
Port View
Here the port 3 is showing that it is measuring the reflected light intensity and that the value it is currently reading is 16.  The distance you have your sensor from the floor will determine the value it reads.  It is important in competition to get a reading as soon as possible so that you can set your values for competition as the ambient light may be very different from your school which will change your readings.

The Orange blocks are the flow blocks - here is an example of the loop block the will move the robot forward for 3 seconds, check if the reflected light is less than the threshold of 10.  If it isn't it will continue moving forward.  The moment it is less than 10 the loop ends and because there are no bricks connected to it the robot will stop. 
Loop
By changing the less than sign to a greater than sign ( > ) you can have the robot move forward until it detects the white strip.

You can put a loop into a loop and you could add blocks so that when your robot reaches the white line it does something (i.e. back up two rotations, turn left 90 degrees then continue the original loop).

Tip: pretend you are the robot and talk through what you want the robot to do - then use the blocks to build the appropriate action.

Techno Girls

Setup directions:
  • Go to Mindstorms.com downloads
  • Download the Ultrasonic Sensor Block
  • Launch the LEGO MINDSTORMS EV3 software
  • Navigate to Tools, and click Block Import, as shown in the figure below.
Install Block
  • Click Browse, and select the file you downloaded earlier.
  • Select Ultrasonic.ev3b in the dialog.
  • Click Import.
  • Close and restart the EV3 software when prompted.

ev3 Robot
Our robot for this challenge is very simple - it moves on two tracks.  The left motor is plugged into port B, the right motor is plugged into port C.  In addition there is an ultrasonic sensor plugged into port 4.

EV3 Program for Techno Girls

Challenges:

  1. Modify this program so that the robot will turn 90 degrees to the right when it encounters a wall - it should be able to go around an entire room!





Subpages (1): Gyro on EV3
Comments