Remote Controlled EV3 Robot with Dual Gyro Sensors

I’m in the middle of another project involving the LEGO EV3 system.  My 11-year old has been making some inquiries about the gyro sensor that came with the EV3 Education kit.  To make the lesson more interesting, I wrote a simple EV3 project to illustrate the use of the gyro sensors, and as a bonus, also to illustrate the use of Bluetooth messaging.

The most common EV3 robot design we have used is the two-wheeled robot.  The two wheels are controlled by independent motors, and can therefore be used to move the robot forward/backward, as well as steer the robot left/right by varying the speed (and rotational direction) applied to the two motors.

The project is to remote control this kind of EV3 robot to move forward/backward and to steer left/right.  Instead of a joystick-like remote control, I want the controller to use gyro sensors, in the same way some smartphones use similar sensors to determine the phone orientation.  Such a controller can technically be attached to an arm, and the movement of the arm controls the robot, making it a hands-free experience.

A hands-free controller like this can accomodate three separate axis of rotations.  Some of you may be familiar with the concepts of pitch, roll, and yaw, such as those used in joysticks that control airplane movement.  For our EV3 robot to move forward/backward and left/right, we only need two axis of rotations.  I used pitch and roll in my simple controller design because those two concepts naturally fit the intended movements of the robot.

The controller is really very simple, with the two gyro sensors on port 2 and 3 of the EV3 brick, attached with a few hassenpins.


The core part of the controller program merely measures, in degrees, the pitch and the roll of the controller and sends them out as Bluetooth messages to another EV3 brick.


The complete controller program has a few more steps added for robustness, debugging, and a mechanism to reset the gyro sensors because of accumulated errors caused by sensor drift.  It is still a relatively small program.


The receiving program in the EV3 robot is also simple.  The core part of the program receives the pitch and roll values, applies gain factors to both of them (to translate the pitch and roll degrees to values that can be applied to an EV3 move and steering block), and sets the parameters for the move and steering block that controls the robot wheels.


The complete receiver program also just has a a few additional steps, mainly to limit the resulting values to fall within –100 to 100, which are the values that can be fed into the move steering block.


Here’s what a sample run of the two programs look like:

This entry was posted in Robotics and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *