IMG_0877 (2)

Although the Lego Mindstorms EV3 kit comes with a variety of cool sensors, wouldn’t it be awesome to build your own custom sensing device? This project will show you how to create your own unique object sensors for your Lego EV3 controller using basic electronic components found in your junk box or purchased from  distributors like RadioShack, Adafruit, Jameco, or SparkFun Electronics.

Think of this DIY object sensor as an electronic substitute for the touch sensor that comes with the EV3 kit. Instead of making physical contact, the object sensor uses light and shadow to detect objects, prompting your EV3 to turn on a motor or sound an alarm. Running some simple code that you’ll upload, the EV3 also displays a pair of expressive eyes on-screen (like Rethink Robotics’ Baxter) based on the presence of an object in its detection space.

What’s Inside a Lego EV3?

The Lego EV3 is a remarkable programmable controller with tons of cool features built in, such as Bluetooth communications, WiFi, USB hosting, and a multi-button user interface. The brain behind the Lego EV3 is a powerful Texas Instruments 456MHz ARM microprocessor. Connected to the TI microprocessor are the EV3’s power supply, USB, I/O (input/output) ports, flash memory, and display buttons, and a GUI (graphical user interface) on an LCD screen. The I/O ports consist of 4 inputs labeled 1, 2, 3, and 4, and 4 outputs labeled A, B, C, and D. The input ports use RJ-12 type connectors for attaching sensors and motors with standard RJ-12 cables. For this project, we’ll be using input port 1 to connect our DIY object sensor to the TI ARM microprocessor.

LEGO_EV3_Block_Diagram

Modifying the LEGO Cable

The key element to building your own sensors is having access to the Lego EV3’s input circuit. In order to connect your DIY object sensor to the EV3 input port 1, you simply need to modify a standard RJ-12 cable. By cutting one of the RJ-12 connectors off the cable and stripping the outer insulation, the 6 individual wires are accessible for attaching the object sensor circuit to it. The DIY object sensor’s relay contacts will connect to 2 of the 6 wires.  

Lego EV3 Code

The programming code for the object sensor is based on the interlocking of function blocks in the EV3 software. Each block provides a certain function related to object detection, response time, and displaying expressive eyes. The cool thing about programming the EV3 is the many sounds and visual effects that can be heard through the mini speaker and displayed on the LCD, respectively. The object sensor’s Robot Eyes code and multimedia effects allow your robot to be more engaging and provide a sense of awareness of its surroundings based on the expressive response. Let’s get started.