Skip to main content

BitCar

Introduction

BitCar is a micro:bit project that designs a smart, programmable robot car to encourage kids’ STEAM learning. After combining programs from Microsoft MakeCode, the robot car will be able to perform line following, obstacle avoidance and even a wheelie. The car carries a speaker itself for playing melodies and sound effect, and has 4 colorful RGB LEDs on the underside of it and a detachable ultrasonic sensor in the front for avoiding obstacles on the way.

note

The micro:bit, USB cable and batteries are not included in the package. You need to prepare them separately. For specific details about how to assemble the car, see Attachment 1 BitCar Assembly Instruction. For details about the cover and chassis, see Attachment 3 BitCar Cover & Chassis.

Tutorials

Here are some example tutorials for you to learn how to use this kit. Let’s get started!

1. Line Following

1.1 Implementation

After the car starts up, it can drive along the track.

See Attachment 2 BitCar Map

1.2 Write a Program

Note that you need to add an extension in MakeCode because it doesn’t have blocks that control the car. Follow the instruction below to add the extension.

  • Let’s go to MakeCode first: https://makecode.microbit.org/

  • Step 1 Create a new project which takes you to the workspace. Click on the gear icon (for setting).

  • Step 2 Click “Extensions” from the drop-down list and then you will enter the extension page.

  • Step 3 Copy and paste this extension link onto the search box: https://github.com/TinkerGen/pxt-BitCar

If a prompt says that this extension does not exist, please close the browser and try again.

  • Step 4 Click the extension icon and go back to the workspace.

After you added the extension, we can start the task.

Firstly, add a “forever” block. If the black line is detected on the left side, the car should make a short left turn so that it can still follow the track. In this case, we set the left motor speed as 3% and the right motor speed as 15%. Similarly, if the black line is detected on the right side, the car should make a short right turn. And we set the right motor speed as 3% and left motor speed as 15%.

You can adjust the motor speed as needed.

1.3 Connect a Device

Slide the micro:bit into BitCar and be careful not to reverse it. Then, connect the micro:bit to your PC with a USB cable. Check if the LED indicator on the micro:bit lights up or not. If not, you need to plug in the USB cable again.

1.4 Upload a Program

The previous tutorials have already shown you how to download the program that you wrote. You just need to rename your program, click the “Download” button and send it to your micro:bit.

1.5 Run a Program

Turn on the switch on the car and see if it can run normally.

2. Obstacle Avoidance

2.1 Implementation

After the car starts up, it can drive along the track and stop as soon as it sees an obstacle.

2.2 Write a Program

Still we use a same method in Tutorial 1 to add the BitCar extension.
Firstly, add a “Forever” block. If the ultrasonic sensor detects an object to a distance smaller than 12, then set the left motor speed as 20% and right motor speed as 0%. Then set a 0.7 s timeout.

2.3 Connect a Device

Slide the micro:bit into BitCar and be careful not to reverse it. Then, connect the micro:bit to your PC with a USB cable. Check if the LED indicator on the micro:bit lights up or not. If not, you need to plug in the USB cable again. Bring out the ultrasonic sensor and install it to the car.

How to install the ultrasonic sensor (see the user manual in the package):

2.4 Upload a Program

You have been introduced how to download your programs in the previous tutorials. You just need to rename your program, click the “Download” button and send it to your micro:bit.

2.5 Run a Program

Turn on the switch on the car and see if it can run normally.

3. RC Car (Controlled by a micro:bit)

3.1 Implementation

After the car starts up, the car will go forward if the button A on micro:bit is pressed down; and it will go backward if the button B is pressed down.

3.2 Write a Program

Still we use a same method in Tutorial 1 to add the BitCar extension.

  • micro:bit Program
    Add an “on start” block. Connect the block “radio set group” into it. Drag and drop the “Forever” block. Follow this program logic: if the button A is pressed, then the radio will send the number “1”; if the button B is pressed, then the radio will send the number “2”.

  • BitCar Program
    Add an “on start” block. Connect the block “radio set group” into it. Follow this program logic: the radio receives a signal “receivedNumber”. If “receivedNumber” equals to 1, then the car will go forward at a 15% speed. If “receivedNumber” equals to 2, then the car will go backward at a 15% speed.

micro:bit Controller Program

BitCar Receiver Program

3.3 Connect a Device

Slide the micro:bit into BitCar and be careful not to reverse it. Then, connect the micro:bit to your PC with a USB cable. Check if the LED indicator on the micro:bit lights up or not. If not, you need to plug in the USB cable again.

note

There are 2 groups of programs, thus you’ll need 2 micro:bits for this project. Use one micro:bit to connect to the power, and the other one to control the car. You also need to write and download programs separately to distinguish the two micro:bits. The micro:bits mentioned in this tutorial are not included in the package.

3.4 Upload a Program

You have been introduced how to download your programs in the previous tutorials. You just need to rename your program, click the “Download” button and send it to your micro:bit.

3.5 Run a Program

Turn on the switch on the car and see if it can run normally.

4. RC Car (Controlled by a micro:bit and a BitPlayer)

4.1 Implementation

If the joystick is pulled up, the car goes forward; if the joystick is pulled back, the car goes backward; if the joystick is pulled to the left, the car turns left; if the joystick is pulled to the right, the car turns right; if the button A is pressed, the car stands up; if the button B is pressed, the car stops.

4.2 Write a Program

Still we use a same method in Tutorial 1 to add the BitCar extension.
BitCar Extension: https://github.com/TinkerGen/pxt-BitCar
BitPlayer Extension: https://github.com/TinkerGen/pxt-BitPlayer

  • BitPlayer Program
    Add an “on start” block. Connect the block “radio set group” into it. Drag and drop a “Forever” block. Start adding blocks under this program logic: if the joystick is pulled up, the radio will send the number “1”; if the joystick is pulled back, the radio will send the number “2”; if the joystick is pulled to the left, the radio will send the number “3”; if the joystick is pulled to the right, the radio will send the number “4”; if the button A is pressed, the radio will send the number “5”; if the button B is pressed, the radio will send the number “6”.

  • BitCar Program
    Add an “on start” block. Connect the block “radio set group” into it. If “receivedNumber” equals to 1, the car will go forward at a 15% speed; if “receivedNumber” equals to 2, the car will go backward at a 15% speed; if “receivedNumber” equals to 3, the right motor speed will be 20% and the left motor speed will be 0%, then the car will go forward at a 15% speed again; if the “receivedNumber” equals to 4, the left motor speed will be 20% and the right motor speed will be 0%, then the car will go forward at a 15% speed again; if the “receivedNumber” equals to 5, the car will do a stand-up act at a 100% speed; if the “receivedNumber” equals to 6, the car will stop.

BitPlayer Program

BitCar Program

4.3 Connect a Device

Slide the micro:bit into BitCar and be careful not to reverse it. Then, connect the micro:bit to your PC with a USB cable. Check if the LED indicator on the micro:bit lights up or not. If not, you need to plug in the USB cable again.

note

There are 2 groups of programs, thus you’ll need 2 micro:bits for this project. One micro:bit is for BitPlayer; the other one is for BitCar. You also need to write and download programs separately to distinguish the two micro:bits. The micro:bits mentioned in this tutorial are not included in the package.

4.4 Upload a Program

You have been introduced how to download your programs in the previous tutorials. You just need to rename your program, click the “Download” button and send it to your micro:bit.

4.5 Run a Program

Turn on the BitCar and BitPlayer. After they match up, observe how the program is runing.

5. Python

In addition to the tutorials above, you can also use Python to control the BitCar. Below is the example program:

5.1 Motor Control

First, we will import all necessary micro:bit modules.

  1. Add your Python code here. E.g.
  2. from microbit import *

Then we define a function called movement(left,right), the value of left and right is the speed (from -255 to 255) for each motor.

1. def movement(left, right):
2. if left > 0:
3. pin13.write_analog(0)
4. pin14.write_analog(left)
5. elif left < 0:
6. pin13.write_analog(left)
7. pin14.write_analog(0)
8. if right > 0:
9. pin15.write_analog(0)
10. pin16.write_analog(right)
11. elif right > 0:
12. pin15.write_analog(right)
13. pin16.write_analog(0)

Define another function called stop(), we call this function to stop the BitCar.

1. def stop():
2. pin13.write_analog(0)
3. pin14.write_analog(0)
4. pin15.write_analog(0)
5. pin16.write_analog(0)

With the functions we just defined above, we can control BitCar as follow:

Move forward in full speed:
movement(255, 255)

Move backward in full speed:
movement(-255, -255)

Spin clockwise:
movement(255, -255)

Stop:
stop()

Course Information and Sample Lesson Download

You can see related micro:bit and BitCar courses on Make 2 Learn via this address: https://make2learn.tinkergen.com

IV Attachments

Attachment 1 BitCar Assembly Instruction:Attachment 1 BitCar Assembly Instruction.pdf

Attachment 2 BitCar Map:Attachment 2 BitCar Map.pdf

Attachment 3 BitCar Cover & Chassis:Attachment 3 BitCar Cover - Chassis.zip

Attachment 4 Source Code:Attachment 4 Source Code.zip

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...