Arduino lego car

Bluetooth Controlled LEGO Toy Car © CERN-OHL

Enjoy teaching your kids basic electronics and as a reward get them a unique Toy.

Arduino UNO
× 1
SparkFun Dual H-Bridge motor drivers L298
× 1
SparkFun Bluetooth Modem — BlueSMiRF Silver
× 1
9V battery (generic)
× 2
9V Battery Clip
× 2
OpenBuilds Wire Cable — By the Foot
× 1
DC motor (generic)
× 2
OpenBuilds Solid V Wheel Kit
× 2

My motivation was my kids. I want to share time and have fun with them teaching them some basic concepts about projects and electronics.

As PM I assigned some tasks for one of them in this project: to build a Lego car to be used for installing the Arduino board, the wheels and motors coupled and space to install 9V batteries. This mission was given in a piece of paper and a specific date was established. My intention is to use this experience in the near future for a GO-KART prototype.

To copy the old idea of building a TOY CAR controlled by Bluetooth from a smartphone.

My main concern about this project is that doesn’t exist batteries that really can be cheap and long time feeder for this kind of toys. So the scientific community has a challenge to solve the problem: How to obtain electric power supply cheap and easy for portable devices and toys and other future devices with motors?

In this case I went on agile techniques to develop projects: few documents, quick schemes and drafts, not complicated engineering, just selecting parts, buying parts, connecting parts, interconnecting parts, plugging and playing with the toy. In projects this orientation is called FFP — Fit For Purpose.


Autonomous Controllable LEGO Car © GPL3+

Autonomous car, built from a LEGO frame, which responds to nearby objects and can also be manually controlled via remote control.

Arduino UNO
A Mega board could be used since the current setup with the UNO uses all the pins with no room for additional changes.
× 1
LEGO Mindstorms NXT Programming Brick / Kit
This contains all the bricks to build the frame, as well as the two motors used to drive the car. 3d printed frames or rc toy car frames can be used alternatives to the LEGO frame and brushed DC motors can be used as alternatives to the two LEGO nxt motors.
× 1
Ultrasonic Sensor — HC-SR04 (Generic)
× 1
28YBJ-48 DC 5V 4 Phase 5 Wire Stepper Motor With ULN2003 Driver Board
Used to rotate the ultrasonic sensor up to 360 degrees and hold position
× 1
SG90 Micro-servo motor
Used to make the «kick» action
× 1
L9110S H Bridge Stepper Motor Dual DC Driver
Alternate can be two individual l9110 ic’s
× 1
HX1838 Universal IR Infrared Remote Control Receiver Module
An ir transmitter can also be bought. I used a Sony TV remote as my transmitter.
× 1
Custom PCB
Minimum 5 * 10 grid to create bumpers
× 2
Tactile Switch, Top Actuated
Used in case ultrasonic sensor fails due to high angle reading
× 4
High Brightness LED, White
For front bumper
× 1
5 mm LED: Red
For back bumper
× 1
Rotary potentiometer (generic)
For speed control
× 1
Through Hole Resistor, 470 ohm
For the 2 LEDs on both the front and back bumpers
× 2
Resistor 10k ohm
For each button (2 on each bumper)
× 4
Jumper wires (generic)
× 20
Alligator Clips
× 6
Soldering iron (generic)
Solder Wire, Lead Free
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Multitool, Screwdriver
Digilent Mastech MS8217 Autorange Digital Multimeter
Helpful to check connections

This project was first intended to be just an autonomous car. Now, it is controllable via an ir remote and there are multiple modes of operation.

Demo of autonomous mode (not all autonomous functions shown):

Demo of few of the features of manual remote control mode:

The frame and body of the car is built entirely from the bricks in the LEGO Mindstorms kit. The construction instructions for the frame were obtained from the website below:

After building the basic frame, I mounted the Arduino Uno in the same place as the Mindstorms NXT battery pack would’ve been according to the instructions above. To attach all the remaining motors/sensors and battery pack, I tried various brick structures to find the sturdiest attachments. I do not have building instructions for these attachments since I just experimented along the way, but the pictures should give a general idea.

The car uses an ultrasonic sensor to measure distance, which is mounted about five inches above a stepper motor. The stepper motor is used heavily when the car is in the autonomous mode to constantly rotate the ultrasonic sensor (to obtain a wide vision radius), as well as check each degree in a circle for an alternate path when an obstacle is detected too close. Additionally, push buttons (both on the front and back of the car) are used in case the ultrasonic module doesn’t detect an object right in front of it (since the reading angle is low for the specific module I used).

A servo motor is attached on the right side of the car. It is connected to a kicker built from LEGOs which is fastened using the servo’s included screws. The car, when detecting an object within 15 cm, will kick its servo, then back up away from the object. This is currently just a fun way to «attack» the object in front of it, but further implications could take use of the servo, for example, to kick the ball in a game of soccer.

When an object is detected greater than 15 cm but within 50 cm, the robot takes various actions to avoid the obstacle. Otherwise, the car drives straight, and at random intervals, looks to change course if necessary.

I used the NXT motors included in the kit to be the driver motors for the car. To be able to control the NXT motors from an Arduino, the NXT cable has to be stripped. Only the two wires on one side (black and white colors) are needed and the other four wires can be ignored. These two wires are then connected to the output pins of a L9110 dual motor driver.