Programming Bluetooth on EV3

IMG_20150228_063709On 27 February 2015, a small group of EDGErs went to LEGOLAND in California for an EV3 Hackathon. This post documents one of the projects that came out of the event.

Wireless projects using Bluetooth technology can be loads of fun and very engaging. They can definitely bring a “wow” factor into your lessons, and foster high levels of autonomy and creativity among your students.

Up until the launch of the EV3, programming with Bluetooth options was new yet fairly straight forward and worked well enough with the NXT and its software. You may have discovered, however, that what once worked with NXT-G no longer works with the EV3 Software. If you’ve had similar Bluetooth experiences on the EV3 then you may find the following information very useful.

Firstly, this article will assume you already know how to pair two EV3 robots together. One of the differences between Bluetooth on the NXT and the EV3 is that there is less of a concern between which robot is the “Slave” and the “Master”. The EV3 appears quite capable of sending and receiving messages irrespective of which device set up the connection.

The video below, taken at the February 2015 EV3 Hackathon at LEGOLAND in San Diego, shows an EV3 “vehicle” tracking both sides of a black line and heading towards a “traffic light” assembly controlled by another EV3. The challenge was to have the traffic lights module detect the vehicle through the ultrasonic motion sensor and send a Bluetooth message telling it to stop. Then after a few seconds instruct the traffic lights to change back to green and allow the vehicle to proceed along its black path.

However, the video shows the EV3 vehicle and traffic lights behaving incorrectly. What we discovered was that if the vehicle was waiting for a correct message to change its behaviour (using a ‘Switch’ block), once it was received, the switch would stay “on”. This condition didn’t appear to exist with NXT-G programming.

At first I thought to use the “Clear” Bluetooth block, but that only disconnected the Bluetooth connection. Finally, after several hours problem solving how to override a Bluetooth message once sent, I came up with a solution by sending an incorrect message. I used another Message Send block and transmitted an incorrect code (I used the code “reset” in my examples below) to force any Switch or Loop into its default mode. Note the highlighted Message blocks and Loop block in the two screen shots for each program.

Vehicle program showing added Message block to reset Loop on Traffic Lights program
Vehicle program showing added Message block to reset Loop on traffic lights program
Part of Traffic Light program showing added Message block to reset Switch on Vehicle program
Part of Traffic Lights program showing added Message block to reset Switch on Vehicle program

You can download the EV3 BlueTooth Projects (Zip file) here and try it out for yourself.

Happy wireless adventures!

The following two tabs change content below.
John Burfoot
John operates as a Science and STEAM Specialist for students in NSW Primary schools. He is also the founder of โ€œSci-rifficโ€ โ€“ a business that provides Professional Development for teachers in Science and LEGO Robotics. John holds a Bachelor of Education (Primary), a Certificate IV in Training & Assessment and is a qualified electronics technician, with experience in avionics and special effects for film and television.
John Burfoot

Latest posts by John Burfoot (see all)