LEGO & Micro:bit RC Tank

by BrownDogGadgets in Circuits > Gadgets

17754 Views, 142 Favorites, 0 Comments

LEGO & Micro:bit RC Tank

LEGO Tank-2461.jpg
LEGO Tank with Remote Control
LEGO Tank-2436.jpg
LEGO Tank-2435.jpg

Here's a fun LEGO project that uses our Bit Board and micro:bit to power an RC tank, and another Bit Board and micro:bit to work as a remote control. We've listed all the LEGO parts we used, and also provided the needed code for the remote control transmitter and receiver.

If you like our projects and want to see more of what we get up to each week please follow us on Instagram, Twitter, Facebook, and YouTube.

Supplies

How Does a Tank Work?

Tank Steering.png
  • Tank Steering works differently than steering for a car. Most cars have rear wheels that are fixed and cannot turn/pivot left or right, and front wheels that can turn/pivot left or right. The turning/pivoting of the front wheels allows the car to make left and right turns (while moving) in addition to just going forward and backward.
  • For a tank the wheels do not turn/pivot left or right, but by spinning the "wheels" (which typically have a set of tracks attached to them) a tank can drive left or right, or even spin around clockwise or anticlockwise depending on if the wheels on opposite sides of the vehicle are turning the same direction or opposite directions.
  • Tank steering is similar to how a wheelchair works. If both wheels spin the same direction one of them rotating faster will allow for turning of the vehicle. If they are spinning opposite directions the vehicle will spin around.
  • Our Obstacle Avoiding Robot and WALL-E projects both use a form of tank steering.

Gather Electronic Parts

LEGO Tank-2393.jpg
  • We're going to use a Crazy Circuits Bit Board along with a micro:bit and two LEGO Compatible 360 Degree Servos. (We'll power it all with a 2 AAA Battery Pack.)
  • The electronics portion of this project will be very easy since we just need to plug the two servos into the Bit Board and then plug the battery pack into the Bit Board.

Gather LEGO Parts

LEGO Parts Chassis.png
  • Gather all of the LEGO parts needed to build the tank chassis.
  • If you don't have these exact parts you can often make substitutions. For instance, if you have longer axles they can still work, or if you have half bushings instead of regular bushings they should work fine.
  • LEGO is about building what you want to build! Consider our guide a suggestion for your own build which should be based on the parts you have available.

Build the Frame

LEGO Tank-2394.jpg
LEGO Tank-2395.jpg
LEGO Tank-2396.jpg
  • The frame will be built using 6 LEGO Beam Frame 5 x 7 parts.
  • Connect them as shown using 10 LEGO Technic Pin with Friction Ridges and Slots.

Reinforce the Frame

LEGO Tank-2399.jpg
LEGO Tank-2401.jpg
LEGO Tank-2403.jpg
  • Once your frame is complete you'll want to reinforce it using 4 LEGO Beam 15 parts.
  • On the top we placed them centered between the front and rear of the vehicle.
  • On the bottom we offset the beams by one hole on the LEGO frame, putting them closer to the rear of the vehicle.
  • You'll need to make sure you leave the center hole on the side of each frame piece open for the axles to go through,

Add Four of the Axles

LEGO Tank-2404.jpg
LEGO Tank-2405.jpg
  • Next we'll add 4 of the LEGO Axle 8 pieces.
  • Use 12 LEGO Bushing to hold the axles in place.
  • Each axle gets three bushings. Two on the outside, and one on the inside.
  • We need to use two separate axles for each "pair" of wheels because they need to spin independently of each other. One long axle won't work.

Add the Axles With Gears

LEGO Tank-2406.jpg
LEGO Tank-2407.jpg
  • The last two axles will be used to drive the vehicle, so we need to add a LEGO Gear with 16 Teeth Unreinforced along with a LEGO Half Bushing.
  • Like the first four axles, there are two bushings on the outside, and then the gear and the half bushing go on the inside of the frame.

Add the Sprockets

LEGO Tank-2408.jpg
LEGO Tank-2413.jpg
  • Slide the 6 LEGO Technic Sprocket Wheel 40.4 parts onto the axles.
  • At this point your vehicle could probably roll around!
  • In the next step we'll add the treads so the drive sprockets can transmit motion to the other sprockets.

Build the Treads

LEGO Tank-2414.jpg
LEGO Tank-2415.jpg
  • You'll need 58 LEGO Large Tread Link to build your treads as each side uses 29 treads.
  • Connect the treads together to form two sets of treads, but don't connect them into a loop yet!

Add the Treads

LEGO Tank-2416.jpg
LEGO Tank-2417.jpg
  • Wrap the treads around the sprockets and attach into a loop by clicking the two end treads together on each set of treads.
  • You should now have a full set of treads on each side of your tank!

Add the Servo Beams

LEGO Tank-2420.jpg
LEGO Tank-2421.jpg
LEGO Tank-2422.jpg
  • We'll use the 4 LEGO Beam 7 parts to raise and mount the servos to the proper position.
  • Use 2 LEGO Technic Pin with Friction Ridges and Slots for each beam and connect them to the frames as shown.

Add the Servos

LEGO Tank-2424.jpg
LEGO Tank-2425.jpg
LEGO Tank-2426.jpg
  • For each servo press a LEGO Gear with 24 Teeth into place on the servo shaft.
  • For each servo use 2 LEGO Long Pin with Friction parts to attach the servo as shown,
  • Make sure the servo wires are facing upward.
  • Make sure the gears line up when putting the servos in place.

Tank Chassis Complete!

LEGO Tank-2428.jpg
  • You should now have a complete tank chassis!
  • Fun fact: In vehicle building this is what would be referred to as a rolling chassis.
  • We still need to add power & control. Also known as batteries and a micro:bit

Gather More LEGO Parts

LEGO Parts Bit Board Mount.png
  • Gather the LEGO parts shown so we can attach our Bit Board to the tank chassis.
  • We're basically making 4 "legs" for the Bit Board so it can be fit into the frame pieces of the chassis.
  • As always, if you don't have these specific parts, others can work. Longer axles? No problem! Less bushings? You can probably still make it work.

Build the Bit Board Legs

LEGO Tank-2429.jpg
LEGO Tank-2431.jpg
  • Slide 3 of the LEGO Bushing parts onto a LEGO Axle 8.
  • Repeat using a second LEGO Axle 8 and 3 more LEGO Bushing parts.
  • Do the same with the two LEGO Axle 5.
  • Place the Bit Board onto the "legs" and add 4 LEGO Bushing pieces to the top.
  • You should have a Bit Board with 4 adjustable legs ready to mount to the tank chassis.

Mount the Bit Board and Battery Pack

LEGO Tank-2432.jpg
LEGO Tank-2433.jpg
LEGO Tank-2434.jpg
  • We chose a very simple method of adding the 2 AAA Battery Pack. We just taped it to the bottom of the Bit Board!
  • Alternately, you can find a way to mount it to the tank chassis beneath the Bit Board, but we though this method was easy and allowed it to work as one single unit.
  • Once you've got the assembly ready you can slide it into the holes of the frame.
  • You can add 2 LEGO Half Bushing to the bottom to hold the Bit Board in place if you want. (Totally optional!)

Connect the Servos

Tank Servos 01.png
Tank Servos 02.png
  • With the Bit Board mounted onto the tank chassis we can now plug in the servos.
  • Plug in the servo connectors with the orange wires next to the numbered pins. The red wire will then be in the + (positive) column and the brown wire will be in the - (negative) column.
  • One servo should be plugged into Pin 13 and the other servo should be plugged into Pin 14.
  • With the servos connected we're ready to load the code onto the micro:bit, so let's keep going!

Load the Code

Code 01.png
  • Connect a USB cable to the micro:bit and then plug it into your computer.
  • We'll be using makecode.microbit.org to program our board. It uses a simple drag and drop block interface.
  • We're going to load the following code for our Tank Motion program: https://makecode.microbit.org/_iwd5Vt2kK54U
  • Load the code, but don't press the button yet! We're not quite ready...

Prepare for Testing

LEGO Tank-2437.jpg
Bit Board with Battery Pack.png
  • Okay, you've got your tank assembled and the code is loaded. We're almost ready to test.
  • If you've still got the USB cable connected you can remove it now.
  • If the tank is on a table you might want to put it on the floor.
  • You'll need to connect the battery pack to the Bit Board for power.
  • One more thing! Make sure the wires running from the servos and the battery pack are not in danger of getting hit by the treads! Secure them away from the treads using LEGO, tape, or rubber bands.

  • Okay, we're ready for testing!

Test It Out!

LEGO Tank with micro:bit
  • The code won't do anything when you first load it onto your micro:bit as it's waiting for you to press a button.
  • So as long as you've disconnected the USB cable, plugged in the battery pack, and placed the tank on the floor...
  • You can press Button A on the micro:bit!
  • Your tank should go through a series of movements. It should go straight, turn left, go backwards, turn right, and then stop.
  • Remember that in the code we set our speed to 30 which is slow, but good for testing. Later we'll change it to 100 for maximum speed!
  • Did it work? If not, re-check all the previous steps. If everything did work properly, we can keep going!

Take It Further

BDGP-2449.jpg
  • There's no doubt our LEGO Tank is totally awesome... but what would make it more awesome?
  • How about a Remote Control for our Tank? Let's keep going and make our tank and RC tank.

What Is Remote Control?

00 Remote Control.png
  • You're probably familiar with remote controls. Usually you press a button and something happens!
  • You may have used a remote control to open a garage door or to change the channel on a TV.
  • Some remote controls use infrared light (like the TV remote) and some use radio signals (like the garage door remote).
  • Our Remote Control system will use the Bluetooth radios built into the micro:bit so one micro:bit can send signals to another micro:bit
  • Our first micro:bit will be a transmitter (which sends signals) and our second micro:bit will be a receiver (which receives the signals).
  • Since our LEGO Tank already has a micro:bit to make it move we just need to build a transmitter and then update the code to make it work.

Build the Transmitter

Tank Remote Circuit.png
BDGP-2444.jpg
  • We'll need to connect two thumbsticks using F/F Jumper Wires. You'll need just three wires per thumbstick.
  • Plug the Left Thumbstick VRX into Pin 1, +5V into the + (positive) column, and GND into the - (negative) column.
  • Plug the Right Thumbstick VRX into Pin 0, +5V into the + (positive) column, and GND into the - (negative) column.
  • Make note of the orientation of the thumbsticks! The connection pins are on top. If you rotate the thumbstick 90 or 180 degrees the direction you move the stick won't match the direction the tank moves.
  • We used our 3D Printed Thumbstick Holder and 3D Printed Battery Holder but you can always get creative with LEGO, tape, and rubber bands.

Load the Transmitter Code

Code Transmitter.png

Connect a USB cable to the micro:bit and then plug it into your computer.

We'll be using makecode.microbit.org to program our board. It uses a simple drag and drop block interface.

We're going to load the following code for our Tank RC Transmitter program: https://makecode.microbit.org/_U2xVirfvU1uR

How the Transmitter Works

Tank Remote Controls.png
  • Each thumbstick will control a set of tracks. One for the left tracks, and one for the right tracks.
  • There are three positions; forward, reverse, and stop. Using combinations of those with the two sets of tracks will allow our tank to go forward, backward, turn left, turn right, and stop.
  • Since our thumbsticks are analog sensors we are just checking for a specific value to be higher or lower than the input.
  • There is no speed control with this method, but it is a feature that could be added with new code.

Load the Receiver Code

Code Receiver.png

Test It Out!

micro:bit powered LEGO Tank Test
  • You're ready to test out your remote controlled tank!
  • We placed our tank top of some LEGO bricks for the test, just so we could more easily observe it. (And so it wouldn't roll away!)
  • Does the motion of the treads match the movement of the thumbsticks? If not, step through the guide again to make sure you've got it all right.
  • If everything is working as it should, enjoy your new Remote Control LEGO Tank!

Take It Even Further!

LEGO Tank RC-2473.jpg
  • How can we make our RC LEGO Tank even more awesome? How about adding a LEGO Gripper to grab things!?
  • We're working on it, and we'll have another guide done soon showing you how to add this to your tank.