The examples in this section intend to show additional aspects of coding for the EV3 motors and sensors. To that end, they introduce the concept of execution loops and sampling period. The sensor data is often recorded to be plotted at the end.

Always try to see what the sensors are seeing. Looking at your data as a function of time is a good starting point. It will help understand why things work (or sometimes don’t) as expected.


Brief Description

One Motor

Run a sinusoidal motor speed output

Two Motors

Run a sinusoidal speed output for two motors

Event Counter

Use the touch sensor as an event counter

Light Intensity

Detect the relative light intensity of a flashlight

Obstacle Detection

Detect an obstacle using the ultrasonic sensor

Infrared Tracking

Track the LEGO® infrared beacon

Gyro Data

Measure angular position and velocity using a gyro


For best graphic display of the results, consider running them in an interactive Jupyter notebook session (instead of a plain old terminal window).