Microbit
Advanced
60 mins
Teacher/Student led
385 points
What you need:
Chromebook/Laptop/PC
Microbit
Move Motor Car

Tilt Remote Control Car

In this step-by-step lesson, you'll learn to control a Move Motor car using a Microbit as a remote controller. You'll program the Microbit to send directional commands to the car based on its tilt. You'll also create code for the car to respond to these commands, resulting in a fully remote-controlled car.
Learning Goals Learning Outcomes Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Introduction

    The aim of this project is to control the Move Motor car by using another Microbit as a remote controller. When you tilt the remote control Microbit in a direction it will send a message to the Microbit in the car which will make it move in that direction.

    You will need the following for this project:

    1. 2 Microbits (1 that goes in the car and 1 for the remote control).
    2. A Move Motor car.

    2 - Program the remote

    We will need to create 2 code projects:

    1. for the Microbit that will be used as the remote control.
    2. and another for the Microbit that will be inside the car.

    Let's create the code for the remote control first. Go to the https://makecode.microbit.org website and create a new project. Call it "Remote Control" or something that let's you know that it's the project for the remote control.

    Once you've created the new project, add the following code to set the radio group to 1. We will do the same later on the for the car project.

    radio.setGroup(1)
    If this project is being done in a classroom with multiple cars then make sure each remote and car set uses a different radio group. Otherwise the signals will get crossed!

    3 - Send message 'forward'

    We are going to use the accelerometer sensor that's in the Microbit to detect when it is tilted forwards and when it is, we will send a message using the radio transceiver. We will also show an arrow point up on the Microbit so we have some visual feedback that this code has triggered.

    Add the following code.

    input.onGesture(Gesture.LogoDown, function () {
        radio.sendString("forward")
        basic.showArrow(ArrowNames.North)
    })

    4 - Send messages 'left', 'right' & 'reverse'

    Now in a similar way add the following code to detect when the Microbit tilts left, right and back and then send the appropriate message and show an arrow.

    Add the following code.

    input.onGesture(Gesture.TiltLeft, function () {
        radio.sendString("left")
        basic.showArrow(ArrowNames.West)
    })
    
    input.onGesture(Gesture.TiltRight, function () {
        radio.sendString("right")
        basic.showArrow(ArrowNames.East)
    })
    
    input.onGesture(Gesture.LogoUp, function () {
        radio.sendString("reverse")
        basic.showArrow(ArrowNames.South)
    })
    

    5 - Send message 'stop'

    We also need to be able to stop the car so we need to program a gesture to send a 'stop' message as well.

    Add the following code.

    input.onGesture(Gesture.ScreenUp, function () {
        radio.sendString("stop")
        basic.showIcon(IconNames.No)
    })

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of DigitalSkills.org. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more