[2021] Start Up Guide for Valenta Micro:bit RC Car With IPad/IPhone

Introduction: [2021] Start Up Guide for Valenta Micro:bit RC Car With IPad/IPhone

About: We design engineering programs and kits for educators and makers. We support students' self-directed and mutually engaging learning experiences.

If you've got your Valenta micro:bit RC car and want to test drive it with your iPad (iPhone), this is the "please read me first" guide. In this tutorial, you can download ready-to-play MakeCode sample file and play immediately.

Setting up the car is made simple. You can download official micro:bit app to your iPad (iPhone) and pair it with "receiver" micro:bit on the car. Micro:bit app has built-in gamepad console.

Pressing gamepad button A, B, C or D will let the car go forward, backward, left or right. Turn on and off on-board LEDs by pressing gamepad button 1 or 2. Calibrate the steering by pressing gamepad button 3 or 4.

This tutorial does not require coding at all. However, what's really fun is to reverse-engineer how it's running under the hood. If you want to discover more, you can further continue reading the following steps to go deeper in the knowledge. Good luck and have fun!

If you want to control your car using two (x2) micro:bits, please review this tutorial instead.

Supplies

iPad (iPhone)

You will use an iOS device (iPad or iPhone) in this tutorial. Make sure you've downloaded micro:bit app in the App store. Please check your device compatibility with the app for using Bluetooth.

Micro:bit

We will need one (x1) micro:bit for the receiver. We've tested and micro:bit version 1 (V1) and version 2 (V2) are working correctly.

Batteries

We recommend using new, single-use four (x4) 1.5V AA batteries for the car.

RC Car Kit

We will need one (x1) Valenta Off-Roader micro:bit RC car. It is Lego technic compatible and equipped with two (x2) micro gear motors on the rear wheels and one (x1) steering servo based on Roberval balance arm mechanism.

You can also refer to the instruction for assembling the car.

Step 1: Copying the Sample File to Micro:Bit

For this project, we've prepared the MakeCode sample file you can download to your computer. Since this sample file is ready to play, you can start playing immediately. This sample file can work with both micro:bit version 1 (V1) and version 2 (V2).

In this step, please download Receiver.hex file below. Connect your computer and a micro:bit via USB cable. Drag and drop Receiver.hex file to the micro:bit and use this as "receiver" micro:bit. Once you've copied the sample file to the micro:bit, disconnect it from your computer.

Mount "receiver" micro:bit on your car and turn on the power switch on the motor controller.

Step 2: Downloading Micro:bit App

Let's go to the App store and search micro:bit app. Download it to your iPad (iPhone).

Open the app and tap Choose micro:bit button for pairing your micro:bit.

Step 3: Pairing a Micro:bit

You have not paired any micro:bit to your iPad (iPhone) yet. Click Pair a micro:bit button.

Step 4: Pressing Button A, B and Reset Buttons

You will need to hold pressing the button A and B and simultaneously press and release the Reset button.

When all the dots in the 5x5 LED matrix flash altogether, click Next button.

Step 5: Tapping the LED Dots

In the micro:bit app, you will need to tap each LED dot just the way exactly shown on the micro:bit 5x5 LED matrix. This LED dot pattern is unique and different for everyone.

Step 6: Pairing to the Device

Click Next button.

Step 7: Searching Via Bluetooth

Make sure that your iPad (iPhone) has Bluetooth ON. Micro:bit app is trying to search and pair with the micro:bit near you.

Step 8: Checking If Pairing Is Successful

If your iPad (iPhone) has paired with your micro:bit successfully, click OK button.

Step 9: Setting Up Gamepad

Let's go back to the top menu and click Monitor and Control button. Click Add (+) button and choose Gamepad in the list.

Step 10: Playing With Gamepad

Click Start button to activate Gamepad. Now you can control your micro:bit using Gamepad.

Pressing gamepad button A, B, C or D will let the car go forward, backward, left or right.

You can light up the LEDs on the motor controller. Pressing gamepad button 1 and 2 will turn on and off the built-in four (x4) LEDs.

By default, the steering of your car is not always straight by the servo equipped in the car.If the steering is not straight ahead, try to calibrate it by pressing gamepad's button 3 or 4. If the car's steering is a little too right, press gamepad button 3 several times to fix it to the left. If the car's steering is a little too left, press gamepad button 4 several times to fix it to the right. Pressing either button will fix the steering angle by 2 degrees to the opposite side.

That's it. Now you can control Valenta micro:bit RC car! If you want to discover how it's running under the hood, you can further continue reading the following steps to go deeper in the knowledge. Good luck and have fun!

Step 11: Removing Micro:bit Paired in the App

The app allows you to set up multiple micro:bits simultaneously.

If you've paired too many micro:bits and if you want to remove one of them, go to the top menu and click Choose micro:bit button. You can find the list of micro:bits you've paired previously. Click Trash button to remove the micro:bit you want.

Step 12: Removing Micro:bit Paired in Bluetooth Setting

We also recommend that you clean up Bluetooth setting occasionally by removing micro:bits you've paired previously.

To clean up previously paired micro:bits in Bluetooth setting on your iPad (iPhone), please follow these steps.

  • Go to Setting.
  • Go to Bluetooth.
  • Click the micro:bit you want to remove.
  • Click Forget this device button.
  • Click OK button.

Step 13: Adding Extensions to MakeCode Editor

Does your MakeCode editor include following extensions? Please open the editor and check if it includes these extensions in the left menu. You will use these extensions in Receiver.hex sample file. If you can't find these extensions, click Extensions in the bottom of the menu. Then, click to add these extensions to the menu one by one.

Servos extension

You will need this extension to define the steering servo's rotation range and angle.

Devices extension

You will need this extension to define the actions assigned to each Gamepad button in micro:bit app on your iPad (iPhone).

Bluetooth extension

You will need this function to control "receiver" micro:bit's digital and analog pins via Bluetooth from your iPad (iPhone).

Valenta extension

We've also built predefined blocks called Valenta extensions that are easy to use for playing Valenta micro:bit RC car especially.

Click Extensions in the bottom of the menu. Within the search box, type https://github.com/4Tronix/Valenta as shown in the attached photo. Click Valenta extensions. Now the extensions are added in the menu.

You will need following blocks in Receiver.hex sample file.

Board_Model blocks

These blocks will be used when you initially code on start block. In this project, you will use Valenta Zero motor controller. Drag and drop select board model Zero within on start block, so "receiver" micro:bit can recognize the type of motor controller we will use for this project.

FireLed blocks

Valenta Zero motor controller has four (x4) LEDs numbered 0, 1, 2, 3. These blocks can light up LEDs in many ways. You can pick up your favorite RGB color you like, set time and adjust brightness.

Step 14: Reviewing Receiver.hex Sample File (Part 1)

Now we will examine Receiver.hex sample file. Open MakeCode editor and click Import button. Open Receiver.hex file you've copied to "receiver" micro:bit.

on start block

This block is called initially at once when "receiver" micro:bit is powered on.

bluetooth io pin service

In Bluetooth extension, drag and drop bluetooth io pin service block. With this block, you can access to "receiver" micro:bit's digital and analog pins via Bluetooth.

select board model zero

In Valenta extension, go to Board_Model and drag and drop select board model zero block. With this block, "receiver" micro:bit can recognize the type of motor controller. You will use Valenta Zero motor controller for the car.

set center to 90

In this project, let's assume that the steering servo is attached to P2 pin on the motor controller. Let's configure that the servo swings from 0 to 180 degrees and its central angle is 90 degrees.

In Variable extension, create a new variable center that keeps the steering servo's angle straight ahead. Drag and drop set center to block and set center to 90 degrees initially.

set servo P2 range from 0 to 180

In Servos extension, drag and drop set servo P2 range from 0 to 180. Make sure to choose P2 pin and the rotation angle ranges from 0 to 180 degrees.

set servo P2 angle to center

In Servos extension, drag and drop set servo P2 angle to center. Make sure to set the angle to the variable center.

Step 15: Reviewing Receiver.hex Sample File (Part 2)

Let's look at the following function blocks that define the direction and the speed of the car.

The car has a micro gear motor M1 on the left rear wheel and M2 on the right rear wheel.

function goForward block

First, let's create goForward function in Functions extension.

digital write pin P13 to 0

P13 pin is used for direction of M1 motor. In Pins extension, drag and drop digital write pin P13 to 0, so that M1 goes forward.

digital write pin P15 to 0

P15 pin is used for direction of M2 motor. In Pins extension, drag and drop digital write pin P15 to 0, so that M2 goes forward.

analog write pin P12 to 1023

P12 pin is used for speed (max speed is 1023) of M1 motor. In Pins extension, drag and drop analog write pin P12 to 1023, so that M1 goes forward at max speed.

analog write pin P14 to 1023

P14 pin is used for speed (max speed is 1023) of M2 motor. In Pins extension, drag and drop analog write pin P14 to 1023, so that M2 goes forward at max speed.

pause (ms) 1000

In Basic extension, drag and drop pause (ms) 1000 block to keep the car going forward for 1000 milliseconds (1 second).

call stop

In Functions extension, drag and drop call stop block to execute function stop. After the car has run for 1 second, it will stop safely.

function goBackward block

Second, let's create goBackward function in Functions extension.

digital write pin P12 to 0

P12 pin is used for direction of M1 motor. In Pins extension, drag and drop digital write pin P12 to 0, so that M1 goes backward.

digital write pin P14 to 0

P14 pin is used for direction of M2 motor. In Pins extension, drag and drop digital write pin P14 to 0, so that M2 goes backward.

analog write pin P13 to 1023

P13 pin is used for speed (max speed is 1023) of M1 motor. In Pins extension, drag and drop analog write pin P13 to 1023, so that M1 goes backward at max speed.

analog write pin P15 to 1023

P15 pin is used for speed (max speed is 1023) of M2 motor. In Pins extension, drag and drop analog write pin P15 to 1023, so that M2 goes backward at max speed.

pause (ms) 1000

In Basic extension, drag and drop pause (ms) 1000 block to keep the car going forward for 1000 milliseconds (1 second).

call stop

In Functions extension, drag and drop call stop block to execute function stop. After the car has run for 1 second, it will stop safely.

function stop block

Lastly, let's create stop function in Functions extension.

digital write pin P13 to 0

P13 pin is used for direction of M1 motor. In Pins extension, drag and drop digital write pin P13 to 0, so that M1 is set for forward direction.

digital write pin P15 to 0

P15 pin is used for direction of M2 motor. In Pins extension, drag and drop digital write pin P15 to 0, so that M2 is set for forward direction.

analog write pin P12 to 0

P12 pin is used for speed (0 means no speed) of M1 motor. In Pins extension, drag and drop analog write pin P12 to 0, so that M1 stops.

analog write pin P14 to 0

P14 pin is used for speed (0 means no speed) of M2 motor. In Pins extension, drag and drop analog write pin P14 to 0, so that M2 stops.

set servo P2 angle to center

In Servos extension, drag and drop set servo P2 angle to center. Make sure to set the angle to the variable center. That way, the car's steering is always straight ahead every time it stops.

(Continuing to the next step)

Step 16: Reviewing Receiver.hex Sample File (Part 3)

Let's define actions that are assigned to each Gamepad button on your iPad (iPhone) in this step.

on gamepad button A down block

In Devices extension, you can find the block on gamepad button A down. This block is executed whenever you press Gamepad button A on your iPad (iPhone). When pressed, the block will call goForward function and the car will go forward.

on gamepad button A up block

In Devices extension, you can find the block on gamepad button A up. This block is executed whenever you release Gamepad button A on your iPad (iPhone). When released, the block will call stop function and the car will stop.

on gamepad button B down block

In Devices extension, you can find the block on gamepad button B down. This block is executed whenever you press Gamepad button B on your iPad (iPhone). When pressed, the block will call goBackward function and the car will go backward.

on gamepad button B up block

In Devices extension, you can find the block on gamepad button B up. This block is executed whenever you release Gamepad button B on your iPad (iPhone). When released, the block will call stop function and the car will stop.

on gamepad button C down block

In Devices extension, you can find the block on gamepad button C down. This block is executed whenever you press Gamepad button C on your iPad (iPhone). When we press button C, we want the car to turn left and go forward. In Servos extension, drag and drop set servo P2 angle to center + 10 degrees to the left. Make sure to set the servo angle by creating center + 10 bracket in Math extension.

on gamepad button C up block

In Devices extension, you can find the block on gamepad button C up. This block is executed whenever you release Gamepad button C on your iPad (iPhone). When released, the block will call stop function and the car will stop.

on gamepad button D down block

In Devices extension, you can find the block on gamepad button D down. This block is executed whenever you press Gamepad button D on your iPad (iPhone). When we press button D, we want the car to turn right and go forward. In Servos extension, drag and drop set servo P2 angle to center - 10 degrees to the right. Make sure to set the servo angle by creating center - 10 bracket in Math extension.

on gamepad button D up block

In Devices extension, you can find the block on gamepad button D up. This block is executed whenever you release Gamepad button D on your iPad (iPhone). When released, the block will call stop function and the car will stop.

(Continuing to the next step)

Step 17: Reviewing Receiver.hex Sample File (Part 4)

Gamepad button 1, 2, 3 and 4 haven't been defined yet with any actions.


Let's use Gamepad button 1 and 2 for defining the function to turn on and off on-board LEDs.

on gamepad button 1 down block

In Devices extension, you can find the block on gamepad button 1 down. This block is executed whenever you press Gamepad button 1 on your iPad (iPhone). Let's turn on on-board LEDs when you press button 1. In Valenta extension, go to FireLed and drag and drop set LED at 0 to (Red) block. Because you have four (x4) on-board LEDs, drag and drop this block four (x4) times. The on-board LEDs are numbered 0, 1, 2 and 3, so let's change the numbers in sequence and choose the RGB colors you like. These blocks would look like something below:

  • set LED at 0 to (Red)
  • set LED at 1 to (yellow)
  • set LED at 2 to (green)
  • set LED at 3 to (blue)

on gamepad button 2 down block

In Devices extension, you can find the block on gamepad button 2 down. This block is executed whenever you press Gamepad button 2 on your iPad (iPhone). Let's turn off on-board LEDs when we press button 2. In Valenta extension, go to FireLed and drag and drop clear all LEDs. This block will clear all the flashing LEDs.


By default, the steering of your car is not always straight by the servo equipped in the car.If the car's steering is not straight ahead, you could calibrate it by pressing Gamepad button 3 or 4. Now let's define the functions to calibrate the steering of the car using Gamepad 3 and 4.

on gamepad button 3 down block

If the car's steering is a little too right, you can press Gamepad button 3 several times to fix it to the left. In Variable extension, drag and drop set center block and make it set center to center + 2. It means you could fix the steering to the left by 2 degrees. In Servos extension, drag and drop set servo P2 angle to center. This center has been updated to the left by 2 degrees.

on gamepad button 4 down block

If the car's steering is a little too left, you can press Gamepad button 4 several times to fix it to the right. In Variable extension, drag and drop set center block and make it set center to center - 2. It means you could fix the steering to the right by 2 degrees. In Servos extension, drag and drop set servo P2 angle to center. This center has been updated to the right by 2 degrees.

That's all about how Receiver.hex sample file is programmed. You have the freedom to customize it to your own way. Have fun!

Block Code Contest

Participated in the
Block Code Contest

Be the First to Share

    Recommendations

    • Edible Art Challenge

      Edible Art Challenge
    • Laser Challenge

      Laser Challenge
    • Made with Math Contest

      Made with Math Contest

    Comments