Lego robotics basics

In my summer of exploring robotics, one of the first ones I was playing with was the Lego EV3 kit.  There are a lot of good videos out that can help with programming the robots and understanding the variety of sensors that are available.  My go to series was from Kevin Briggs ( who has a perfect explanation (with code) to help you with the basics.

The main sensors available are the ultrasonic sensor, gyro-sensor, touch sensors, and the color sensor (this one is tricky because it needs to have “Lego” colors).  The sensors I worked the most with were the ultrasonic and the touch sensors, as I was most curious about makes a self-driving robot that can avoid obstacles.

I had played around with one of these a year before but had a lot of trouble using the sensors that were available.  The biggest thing I noticed from the tutorials is that you need to setup the sensor, and then using a logic statement, you need to make the loop continue or not for autonomy.  Lego has a control setup in the loop structure but I was finding that it would not work appropriately because it was an end loop check rather than a beginning loop check.  For example, it will drive then look for the wall and then drive again, so if it is close to the wall it will crash as opposed to stopping when it gets within a range.  Also it is a lot easier to make the distance check work within the given range with a control statement setup at the start of a loop.

Last year I had students play with the robots to learn how to use them better and the students were unable to make the loops work correctly.  Unfortunately I did not have the time to look at it closer but now I can show them some basic programs that can help with understanding how the robot will move.

Below is an example of a distance sensor in action.  The robot will continue straight unless it is within 10cm of a wall (or object).  The structure is set up that it will check for a distance less than 10cm, if it is within that range, it will reverse and turn left, if it is not, it will drive forward.  This is in a loop so it will go on forever.


The best way to make a robot to be autonomous with the EV3, is to set it up similar to this.  You simply change the sensor (the yellow) and then the condition (the red), and then make it complete the steps in the true (check-mark) and the false (x) in order to make the robot function endlessly.

I find that this robot is perfect for high school students to learn about robotics and procedural learning because it is easy to use for basic movement, and the software comes pre-loaded with tutorials to teach them how to drive the car and learn the functions.  It is also nice because the students can try to build a better robot with the pieces and even the GyroBoy, that has instructions included in the software.  This is also nicer than Arduino for new learners because it does not require any code to write and is a good progression from scratch (and the hour of code).


Here is the touch sensor code:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s