Ks0426 keyestudio Micro:bit Mini Smart Robot Car Kit V2

From Keyestudio Wiki
Jump to: navigation, search
Keyestudio Micro:bit Mini Smart Robot Car V2



Description

Here comes a mini STEM education DIY robot platform based on Micro:bit programming.
Micro: bit is an ARM structure microcontroller designed by BBC. It is only half size of a credit card, onboard comes with Bluetooth, accelerometer, compass, three buttons, 5x5 LED matrix, mainly used for teens programming education.
The Micro:bit Mini Smart Robot Car V2 integrates ultrasonic and infrared obstacle avoidance, line following as well as infrared and Bluetooth control functions.
It comes with a passive buzzer for playing music; a KEYES-2812-18R module for controlling 18 RGB LED colors; a photocell for detecting the light intensity; two RGB lights used as direction light.
Moreover, the micro:bit car supports charging by 18650 batteries when run out of power. It is available to adjust the motor speed.
This micro:bit robot is a perfect toy for kids to start learning robotics. The plug-and-play allow children to quickly learn graphic programming in entertaining, nurturing children's interest in science and logical thinking.


Specifications

  • 1) Voltage: DC 5V
  • 2) Current: USB power supply or power supply with a capacity greater than or equal to 1A
  • 3) Maximum power: maximum output power is 10W
  • 4) Operating temperature range: 0-50 degrees Celsius
  • 5) Dimensions: 120*90.7mm
  • 6) Environmental attributes: ROHS


Packing List

Note: the Micro:bit main board is Not Included!

No. Specification Quantity Picture
1 Acrylic pack of 3 pieces T=3MM 1
thumb
2 Micro:bit robot bottom shield V2 (Black and Eco-friendly) 1
thumb
3 HC-SR04 ultrasonic sensor 1
thumb
4 KEYES-2812-18R Module(welded with yellow curved pin) 1
thumb
5 N20 motor wheel diameter:43mm ; width: 19mm ; hole diameter: 3mm type DABS plastic + rubber yellow 2
thumb
6 steel universal wheel W22*H15MM 1
thumb
7 M1.6*10MM round head screw 8
thumb
8 M3*6MM round head screw 8
thumb thumb thumb thumb
9 M1.6 304 stainless steel nut 8
thumb
10 Double pass M3*35MM hex copper pillar 4
thumb
11 M3*10MM flat-head screw 1
thumb
12 M3 Nickel plated nut 1
thumb
13 M2*12MM round head screw 8
thumb
14 M2 Nickel plated nut 8
thumb
15 yellow-black handle 3*40MM phillips screwdriver 1
thumb
16 USB cable A/MICRO OD: 4.0 Black with magnetic spring L=1.2m Eco-friendly 1
thumb
17 Male to female jumper wire 10CM random color 3
thumb
18 Male to female jumper wire 15CM random color 4
thumb


Robot Installation

Firstly prepare all the assembly components before install the micro:bit robot.
thumb thumb

A.Next let’s begin to install the wheel on Micro:bit bottom shield. Prepare well universal wheel, two yellow wheels, 4pcs M3*6MM round-head screws and 4pcs dual-pass M3*35MM hex copper pillars.
thumb

B.To begin with, should use two screws of universal wheel to mount the wheel on the bottom shield.
thumb
The front and back view are shown as below picture:
thumb

After that, install two yellow wheels into the shield’s motor.
thumb

C.Mount the 4pcs M3*6MM round-head screws and 4pcs dual-pass M3*35MM hex copper pillars onto the bottom shield.
thumb

D.Well, ready to install the electronic elements:

  • Two Acrylic plates
  • Ultrasonic module
  • KEYES-2812-18R module
  • Micro:bit main board
  • 6pcs M1.6*10MM round-head screws
  • 6pcs M1.6 304 stainless steel nuts
  • 4pcs M3*6MM round-head screws
  • 1pcs M3*10MM flat-head screw
  • 1pcs M3 nickel plating nut
  • F-M Jumper wires


thumb

At first fix the KEYES-2812-18R module on the Acrylic plate with 2pcs M1.6*10MM round-head screws and 2pcs M1.6 304 stainless steel nuts.
thumb

thumb

Then mount the HC-SR04 ultrasonic module on the Acrylic plate with 4pcs M1.6*10MM round-head screws and 4pcs M1.6 304 stainless steel nuts.
thumb

thumb

Installed well, fix the two Acrylic plates together with 1pcs M3*10MM flat-head screw and 1pcs M3 nickel plating nut
thumb

thumb

E.Finally you should get the parts below:
thumb


Hookup Guide: Connect the KEYES-2812-18Rmodule and HC-SR04 ultrasonic module to the bottom shield with F-M jumper wires.
thumb

thumb

The final step is to mount the Acrylic plates on the 4pcs dual-pass M3*35MM hex copper pillars of micro:bit bottom shield with 4pcs M3*6MM round-head screws.
thumb

Insert the micro:bit main board into bottom shield. Congrats! The fantastic micro:bit robot is installed well.
thumb

micro:bit Driver Installation

Next, let’s install the driver for micro:bit main board.
1) First of all, connect the micro:bit to your computer using a USB cable.
thumb

2)Then, double click the driver software to install it. Here you can click the icon below to download it.thumb

thumb

3) After that, click Next to continue the installation.
thumb

4) Wait the driver installing finished.
thumb

5) Wait the driver installing finished.
thumb

6) Driver installation completed, then you can right click the “Computer” —> “Properties”—> “Device Manager”.
thumb
You can check the detailed Ports information shown as below.
thumb


micro:bit Example Use


Step 1: Connect It

Connect the micro:bit to your computer via a micro USB cable. Your micro:bit will show up on your computer as a drive called 'MICROBIT'.
thumb

Step 2: Program It

Using micro bit MakeCode Block editor https://makecode.microbit.org/, write your first micro:bit code.
You can drag and drop some example blocks and try your program on the Simulator in the Javascript Blocks Editor, like in the image below.
thumb

Click the JavaScript, you can see the corresponding program code. Shown as below figure.
thumb

Step 3: Download It

Click the Download button in the editor. This will download a 'hex' file, which is a compact format of your program that your micro:bit can read. Here you can name the project as LED1, then click “Save”. Shown below.
thumb

Once the hex file has downloaded, copy it to your micro:bit just like copying a file to a USB drive. On Windows find the microbit-LED1 file, you can right click and choose "Send To→MICROBIT."
thumb

thumb


Step 4: Play It

The micro:bit will pause and the yellow 5*5 LED on the back of the micro:bit will display the images while your code is programmed.
thumb

You can power it using USB cable or battery. The battery holder need to connect two 1.5V AA batteries. Shown below.
thumb


micro:bit Pins

Before getting started with the following projects, first need to figure out each pin of micro:bit main board. Please refer to the reference diagram shown below.
thumb
The BBC micro:bit has 25 external connections on the edge connector of the board, which we refer to as ‘pins’. The edge connector is the grey area on the right side of the figure above. There are five large pins, that are also connected to holes in the board labelled: 0, 1, 2, 3V, and GND. And along the same edge, there are 20 small pins that you can use when plugging the BBC micro:bit into an edge connector.

Note that it read from the BBC micro:bit official website. More reference you can click the link below:
BBC micro bit Pins: http://microbit.org/guide/hardware/pins/
BBC micro:bit website: http://microbit.org/
Micro bit MakeCode Block Editor: https://makecode.microbit.org/
Meet micro:bit starter programming: http://microbit.org/guide/
BBC micro:bit Features Guide: http://microbit.org/guide/features/
BBC micro:bit Safety Warnings: http://microbit.org/guide/features/
BBC micro:bit Quick Start Guide: http://microbit.org/guide/quick/

thumb thumb


Get Started with Micro:bit Robot Projects


Get Knowledge of Micro:bit Shield Elements

thumb


Playing Music

Description:
Buzzers can be categorized as active and passive ones.
The difference between the two is that an active buzzer has a built-in oscillating source, so it will generate a sound when electrified. A passive buzzer does not have such a source, so DC signal cannot drive it beep.
Instead, you need to use square waves whose frequency is between 2K and 5K to drive it.
Different frequencies produce different sounds.
You can use micro:bit to code the melody of a song, quite fun and simple.

passive buzzer

The keyestudio Micro:bit robot shield comes with a passive buzzer element. The signal terminal of buzzer is connected to the P0 interface of micro:bit main board.
In the experiment, we make use of the software built-in library to drive the passive buzzer play a song of Happy Birthday.

thumb


Source Code

thumb


What will you see
Send well the test code to micro:bit main board, then insert the micro:bit main board into the micro:bit robot shield.
Connect a 18650 battery to the shield, and turn the POWER and BUZZER switch ON.
You should hear the micro:bit robot shield playing a song of《Happy Birthday》


Micro:bit LED Matrix Display

Description
LED stands for Light Emitting Diode. The micro:bit has 25 individually-programmable LEDs, allowing you to display text, numbers, and images.
The micro:bit MakeCode Block editor has built-in library. So you can use it to control the 25 LED lights on and off, showing the different images.
In the experiment, we drive the 25 LED lights show a big heart and a small heart images.

thumb


Test Code

thumb


What will you see
Send well the test code to micro:bit main board, powered on, the micro:bit 25 LED lights show a big heart for one second, then show a small heart image for one second, repeatedly.

thumb


RGB Light Cycle

Description:
The KEYES-2812-18R module comes with 18 WS2812 LED lights and a yellow pin header, fully compatible with micro:bit main board.
In this circuit, we are going to control 18 WS2812 LEDs displaying different status by using control pin P5 on micro:bit main board.

KEYES-2812-18R module


Source Code
Note: before setting the test code, you need to add the libraries. Follow the instructions below:
Open the micro:bit Software MakeCode editor https://makecode.micro:bit.org/ Click to add New Project, then you will see the interface below:
thumb

Then click Advanced, find the Extensions to add file.
thumb
Search “neopixel”, then add the library file.
thumb

thumb

Library added well, you should see the Neopixel on the Blocks interface.
thumb


Test Code 1:
You can drag the code file to the MicrosoftMakeCode window.
thumb


What will you see
Send well the test code to micro:bit main board, then insert the micro:bit main board into the micro:bit robot shield. Connect a 18650 battery to the shield, and turn the POWER switch ON.
You should see the 18 RGB LEDs on the KEYES-2812-18R module are all turned on, changing with seven colors separately and circularly.
thumb

Note: here we have only introduced the use method of test code 1. But we provide the source code of 1-4 in the folder. The use method is almost the same. You are able to open the program on the micro:bit makecode environment or directly send to micro:bit main board.
If upload the test code 2, 18 RGB LEDs flash with colorful light, turning a round and then off.
If upload the test code 3, 18 RGB LEDs turn circle, one circle of one color, always cycle;
If upload the test code 4, one LED turns circle, and each light is in a random color.

thumb


RGB Light Test

Description:

Ks0426 list2.png

There are two RGB lights on the robot shield. You will learn how to make the two RGB lights as indicator for the micro:bit robot. To save the IO port resources, we will use a PCA9685PW chip to drive the two RGB lights.
In the circuit, Pin LED 4 of PCA9685PW chip is used to control the blue light of RGB; pin LED 5 controls the green light, while pin LED 6 controls the red light.
In this lesson, you will learn how to drive the two RGB LEDs circularly light up the red, green and blue light colors. Another one is to show different color of light.

Source Code
Note: before setting the test code, you need to add the libraries. Follow the instructions below:
Open the micro:bit Software MakeCode editor https://makecode.micro:bit.org/ Click to add “New Project”, then you will see the interface below:
thumb

Then click Advanced, find the Extensions to add file.
thumb

Enter https://github.com/jdarling/pxt-pca9685 and search.
thumb

Then you will get the pca9685 below:
thumb

Click the pca9685 to download the extension:
thumb

Finally you should see the PCA9685 project is added successfully.
thumb


Test code 1:

thumb

Test code 2:

thumb


What will you see
Send well the test code 1 to micro:bit main board, then insert the micro:bit main board into the micro:bit robot shield. Connect a 18650 battery to the shield, and turn the POWER switch ON.
The two RGB LEDs on the robot shield flash in three colors, red, green and blue.

With the same method, upload the test code 2, the 2 RGB LEDs on the robot shield will gradually change with different colors.

thumb


Light Sensing


thumb

Description:
The micro:bit robot shield comes with a photocell sensor element controlled by P1 interface.
Photo resistor (Photovaristor) is a resistor whose resistance varies with different incident light strength.

photoresistor

In the project, we will use the photocell sensor to detect the ambient light intensity, controlling the color brightness of 18 WS2812 LEDs on the KEYES-2812-18R module.

RGB Light Cycle

The darker the ambient light, the brighter the 18 LEDs.


Source Code
Note: here involves KEYES-2812-18R RGB module. Before setting the test code, you need to add the libraries. Follow the instructions mentioned above (RGB Light Cycle)

thumb


What will you see
Send well the test code to micro:bit main board, then insert the micro:bit main board into the micro:bit robot shield. Connect a 18650 battery to the shield, and turn the POWER switch ON.
The 18 WS2812 LEDs are turned on.
The darker the light intensity, the brighter the white light.
thumb

Motor Driving

Description:
The micro:bit robot shield has built-in PCA9685PW and TB6612FNG chips. To save the IO port resources, we can control the TB6612FNG chip through PCA9685PW chip; then control the moving direction and speed of two DC motors by TB6612FNG chip.

Pin LED1 and LED2 of PCA9685PW chip are separately used to control the direction and speed of the left motor;
Pin LED3 and LED4 separately control the direction and speed of the right motor.

In the code, LED1 and LED3 are setting the moving direction.
When the front number are set to 0, motor turns forward; set to 100, motor turns reverse.


thumb thumb

In the code, LED2 and LED4 are setting the motor’s speed, in the range of 0-100. The greater the value, the faster the speed.

thumb thumb

Below table is the running status settings of Micro:bit robot:
thumb


Source Code
Note: here need to drive PCA9685PW chip. Before setting the test code, you need to add the libraries.
Follow the instructions mentioned above (RGB Light Test)


thumb


What will you see
Send well the test code to micro:bit main board, then insert the micro:bit main board into the robot shield, and connect a 18650 battery. Turn the POWER switch ON.
The micro:bit robot will go forward for 2 seconds, backward for 2 seconds, stop for 1 seconds, turn left for 1 second and turn right for 1 second, circularly and repeatedly.


Line Tracking Robot

thumb


Testing the tracking sensor

Description:
The micro:bit robot shield comes with two line tracking sensor elements. Also comes with two potentiometers used for adjusting the sensitivity of sensor.
The tracking sensor is actually an infrared sensor. The component used here is the TCRT5000 infrared tube.
Its working principle is to use the different reflectivity of infrared light to the color, then convert the strength of the reflected signal into a current signal.
During the process of detection, black is active at HIGH level, but white is active at LOW level.

The two line tracking sensors are controlled by P12 and P13 of micro:bit main board.
The left tracking sensor is controlled by P12; the right one is controlled by P13.
Place a white paper in the robot bottom; adjust the potentiometer (RP1; RP2);
Once the D2 and D6 led indicator turn on, the sensitivity is adjusted well.

thumb

Source Code

thumb

What will you see
Send the test code to micro:bit main board, then insert the micro:bit main board into the robot shield; connect a 18650 battery; then turn the POWER switch ON.
When the left tracking sensor detects an obstacle, the micro:bit LED matrix will showⅠat the left side;
When the right tracking sensor detects an obstacle, the micro:bit LED matrix will showⅠat the right side;
When both tracking sensors detect an obstacle, the micro:bit LED matrix will show a big heart image;
When both tracking sensors do not detect an obstacle, the micro:bit LED matrix will show a small heart;

thumb


How to Build a Line Tracking Robot


Overview:
In the previous projects, we have introduced the principle and application of line tracking sensor and motor driving. We’re now ready to give the Micro:bit robot an upgraded capability - Line tracking!

What is line tracking?
Line tracking is exactly what it sounds like - following the track. The robot can always stay on its black track.

How does it work?
It uses the tracking sensor to detect the black track on the pavement, and detection signal will feed back to the micro:bit main board. Then micro:bit main board will analyze and judge the collected signals to control and drive the motor in time, thus can adjust the robot turning direction.
That is why the micro:bit car can automatically follow the black track, achieving the automatic line tracking function.
Programming Thinking
① Set the KEYES-2812-18R module to turn on 18 RGB LEDs in various colors.
② Judge white and black line by both side line tracking sensors.
③ If right side tracking sensor detects black line, robot turns right; if left side tracking sensor detects black line, turn left; if both side sensors don’t detect black line, stop; if both side sensors detect black line, go forward.


Source Code

thumb


What will you see
Send the test code to micro:bit main board, then insert the micro:bit main board into the car shield; connect a 18650 battery, and turn the POWER switch ON.
The micro:bit robot will move forward along the black track.
Ks0426 result9.png


Note:
1)The width of black track should be greater than the distance between the two tracking sensors.
2)Do not test the robot in the sun. If appear problems during the test process, try testing the robot in a rather dark environment.


Ultrasonic Following Robot

thumb


Ultrasonic Ranging

Description:
There is an animal called bat in nature. The bats can fly at night, not depend on its eyes, but on its ears and vocal organs. When the bat flies, it will emit a scream, an ultrasonic signal that humans cannot hear because of its high audio frequency. If these ultrasonic signals hit other objects on the flight path, they will be reflected back immediately. After receive the returned information, the bats complete the whole process of listening, seeing, calculating and bypassing obstacles during the flutter.

thumb

The principle of the ultrasonic module is as the same as the above principle.
The ultrasonic module will emit the ultrasonic waves after trigger signal. When the ultrasonic waves encounter the object and are reflected back, the ultrasonic module outputs an echo signal, so it can determine the distance of object from the time difference between trigger signal and echo signal.
Ultrasonic sensor has a wide range of sensitivity, no blind area, and no interference with obstacles.
As the following picture shown, it is our keyestudio ultrasonic module. It has two something like eyes.
One is transmitting end, the other is receiving end.

thumb



TECH SPECS:

  • Operating Voltage: 5V(DC)
  • Operating Current: 15mA
  • Operating Frequency: 40khz
  • Maximum Detection Distance: 3-5m
  • Minimum Detection Distance: 3-4cm
  • Sensing Angle: less than 15 degrees


thumb


When using it:
(1) Use IO trigger ranging, at least 10us HIGH level signal; that is, first pull the Trip Low, then give a HIGH level signal of 10us.
(2) The module automatically sends eight square waves of 40khz to automatically detect whether there is a signal return back;
(3) There is a signal return, through the IO output a High level, and the duration period of High level is the time of Ultrasonic wave from emission to return.

Test distance = (High level time * speed of sound (340M/S))/2;
Then you can get the formula: detection distance = (High level time/58) (cm);

thumb


Source Code:

thumb


What will you see
Send the test code to micro:bit main board, then insert the micro:bit main board into the robot shield and connect a 18650 battery; turn the POWER switch ON.
When the measured distance between an obstacle and ultrasonic module is less than 10cm, the passive buzzer on micro:bit shield will beep up.


Note:
Open the Arduino IDE, select the proper board and COM port; then open serial monitor and set the baud rate to 115200, the measured distance value will print out on the monitor window.
thumb

Here you can click the link below to get more use details of Arduino IDE.
https://wiki.keyestudio.com/Ks0001_keyestudio_UNO_R3_BOARD


How to Build an Ultrasonic Following Robot


Overview:
In the previous project, we have introduced how to build an obstacle following robot.
This project we use an ultrasonic module combined with micro:bit robot shield to build an ultrasonic obstacle following robot.

How does it work?
The principle is very simple. We will use an ultrasonic module to measure the distance between the micro:bit robot and an obstacle ahead. Then control the running state of micro:bit robot car according to the measured distance.

Programming Thinking
① Set the KEYES-2812-18R module to turn on 18 RGB LEDs in various colors. When micro:bit robot moves forward, 18 RGB LEDs turn on blue light; robot moves backward, 18 RGB LEDs turn on purple light; robot stops, 18 RGB LEDs turn on red light.
② Measure the distance between the robot and obstacles using an ultrasonic sensor.
③ When the measured distance is greater than or equal to 10cm, the micro:bit robot moves forward; if less than or equal to 6cm, robot will move backward; if greater than 6cm but less than 10cm, or greater than 30cm, robot will stop.


Source Code
thumb


What will you see
Send the test code to micro:bit main board, then insert the micro:bit main board into the robot shield and connect a 18650 battery; Turn the POWER switch ON.
The 18 RGB LEDs on the KEYES-2812-18R module will emit different colors.
The micro:bit robot will follow along the front object.
Ks0426 result11.png

Note that the object can only move in front of the robot, can’t turn around.


Obstacle Avoiding And Following Robot

thumb



Infrared Avoiding Obstacles


Overview:
The micro:bit robot shield comes with two infrared obstacle avoidance sensors. It is actually designed for infrared obstacle avoidance robot.

Infrared sensor.png

The infrared obstacle detector sensor has a pair of infrared transmitting and receiving tubes.
The transmitter emits an infrared rays of a certain frequency. When the detection direction encounters an obstacle (reflecting surface), the infrared rays are reflected back, and receiving tube will receive it.
At this time, the indicator (SIG1/SIG2 LED) lights up. After processed by the circuit, the signal output terminal will output Digital signal.
You can rotate the potentiometer on the shield to adjust the detection distance. It is better to adjust the potentiometer to make the SIG1/SIG2 LED in a state between on and off. The detection distance is the best, almost 10cm.


Programming Thinking
① Set the control pin of left infrared obstacle avoiding sensor to P2; the right one set to P11.
② Measure the HIGH/LOW level of both sensors’ control end. Obstacle detected, signal end LOW; no obstacle, signal end HIGH.
③ Judge whether there is obstacles according to the level feedback of sensor’s signal end; make the micro:bit LED matrix show the patterns.


Source Code

thumb


What will you see
Send the source code to micro:bit main board, then insert the micro:bit main board into the robot shield and connect a 18650 battery; turn the POWER switch ON.
The two infrared obstacle detector sensors on the micro:bit robot shield can detect an obstacle ahead.

  • If both infrared sensors do not detect obstacles, the LED matrix will show an upward arrow.
  • If both infrared sensors detect obstacles, the LED matrix will show a smile face.
  • If the left infrared sensor detects an obstacle but right one doesn’t, the LED matrix will show a leftward arrow.
  • If the right infrared sensor detects an obstacle but left one doesn’t, the LED matrix will show a rightward arrow.


thumb


How to Build an Obstacle Avoiding Robot?


Overview:
This project you will learn how to combine an ultrasonic module, infrared obstacle sensor and micro:bit robot shield to build an ultrasonic obstacle avoiding robot.

How does it work?
The principle is very simple. We will use an ultrasonic module to measure the distance between the micro:bit robot and an obstacle ahead. Then detect the left and right side obstacles using infrared obstacle sensors; control the running state of micro:bit robot according to the measured result.

Programming Thinking
① Set the KEYES-2812-18R module to turn on 18 RGB LEDs in various colors. When micro:bit robot moves forward, 18 RGB LEDs turn on blue light; robot moves backward, 18 RGB LEDs turn on red light; turn left, 18 RGB LEDs turn on purple light; turn right, 18 RGB LEDs turn on yellow light.
② Measure the distance between the robot and obstacles using an ultrasonic sensor.
③ When the measured distance is greater than 10cm, make use of infrared sensors to detect obstacle at both sides:
If no detecting obstacles at both sides, robot moves forward; if obstacles are at right side but not left side, robots turn left; if obstacles are at left side but not right side, robots turn right; if both sides have obstacles, robot will go back for 0.1 second then turn left.
④ When the measured distance is less than or equal to 10cm, make use of infrared sensors to detect obstacle at both sides:
If no detecting obstacles at both sides, robot turns left; if obstacles are at right side but not left side, robot turns left; if obstacles are at left side but not right side, robot turns right; if both sides have obstacles, robot will go back for 0.1 second then turn left.


Source Code

thumb


What will you see
Send the test code to micro:bit main board, then insert the micro:bit main board into the robot shield and connect a 18650 battery; Turn the POWER switch ON.
The micro:bit robot is ready to avoid an obstacle ahead to move freely.

Ks0426 result13.png

How to Build an Object Following Robot?


Overview:
In the previous project, we have built an ultrasonic following robot combined with ultrasonic module and robot bottom shield. But the robot can’t turn around, only follow in a straight line.
We’re now ready to give the Micro:bit robot another upgraded capability - Object Following!
Combine ultrasonic module, infrared detector sensor and robot shield to build an obstacle following robot that can turn around.


How does it work?
The principle is very simple. We will use an ultrasonic module to measure the distance between the micro:bit robot and an obstacle ahead. Then detect the left and right side obstacles using infrared obstacle sensors; control the running state of micro:bit robot according to the measured result.


Programming Thinking
① Set the KEYES-2812-18R module to turn on 18 RGB LEDs in various colors.
When micro:bit robot moves forward, 18 RGB LEDs turn on blue light;
robot moves backward, 18 RGB LEDs turn on purple light; turn left, 18 RGB LEDs turn on green light;
turn right, 18 RGB LEDs turn on yellow light; robot stops, 18 RGB LEDs turn on red light.
② Measure the distance between the robot and obstacles ahead by an ultrasonic sensor. Use 2 infrared detector sensors to detect the obstacles on both sides of micro:bit robot.
③ When the measured distance is greater than 3cm but less than or equal to 6cm, no obstacles at both sides, micro:bit robot stops. If less than or equal to 3cm, obstacles detected at both sides, robot moves backward;
If greater than 6cm, no obstacles detected at both sides, robot moves forward;
If greater than 3cm, obstacles are at right side but not left side, robot turns right;
If greater than 3cm, obstacles are at left side but not right side, robot turns left;
If greater than 6cm, obstacles detected at both sides, robot moves backward;
for other status, robot stops.


Source Code

thumb


What will you see
Send the test code to micro:bit main board, then insert the micro:bit main board into the robot shield and connect a 18650 battery; Turn the POWER switch ON.
The micro:bit robot will follow the front object straight or turn around.

Ks0426 result14.png


Infrared Control Robot

thumb


Infrared Remote Control


Overview:
IR Remote Control Decoding:
There is no doubt that infrared remote control is commonly seen in our daily life. It's hard to imagine our world without it. An infrared remote control can be used to control a wide range of home appliances such as television, audio, video recorders and satellite signal receivers.
Well, in the following let’s get a better understanding of the infrared remote control.
Infrared remote control is composed of infrared transmitting and infrared receiving systems. That is, consist of an infrared remote control, an infrared receiver module and a microcontroller that can decode.
You can refer to the figure below.

thumb

KS0364 - 图片8.png


The 38K infrared carrier signal transmitted by an infrared remote controller is encoded by an encoding chip inside the remote controller. It is composed of a pilot code, user code, data code, and data inversion code.
The time interval between pulses is used to distinguish whether it is a signal 0 or 1. (when the ratio of high level to low level is about 1:1, considered as signal 0.) And the encoding is just well composed of signal 0 and 1.

The user code of the same button on remote controller is unchanged. Using difference data distinguish the key pressed on the remote control.
When press down a button on the remote control, it will send out an infrared carrier signal. And when infrared receiver receives that signal, its program will decode the carrier signal, and through different data codes, thus can judge which key is pressed.
The microcontroller is decoded by an received signal 0 or 1 to determine which key is pressed by the remote control.


Infrared Receiving:
The robot shield comes with infrared receiver module. It is mainly composed of an infrared receiving head. This device integrates with reception, amplification and demodulation.
Its internal IC has been demodulated, outputting Digital signal. Suitable for IR remote control and infrared data transmission.

Ks0426-.png


Specification Parameters:

  • 1) Operating Voltage: 3.3-5V(DC)
  • 2) Output Signal: Digital signal
  • 3) Receiving Angle: 90 degrees
  • 4) Frequency: 38khz
  • 5) Receiving Distance: 18m


Source Code
Note: before setting the test code, you need to add the libraries. Follow the instructions below:
Open the micro:bit Software MakeCode editor https://makecode.micro:bit.org/ Click to add “New Project”, then you will see the interface below:
thumb

Then click Advanced, find the Extensions to add file.

thumb

Enter https://github.com/jhlucky/maqueen and search.
thumb

Then you will get the maqueen file below:
thumb

Click the maqueen file to download the extension:
thumb

Finally you should see the maqueen project is added successfully.
thumb


Code:

thumb


Test Result:
Send the test code to micro:bit main board, then insert the micro:bit main board into the robot shield and connect a 18650 battery; turn the POWER switch ON.
Aimed at the infrared receiver head, press the button on the infrared remote controller, the serial monitor will show the corresponding key value.

Note:
Open the Arduino IDE, select the proper board and COM port; then open serial monitor and set the baud rate to 115200, the measured distance value will print out on the monitor window.
Ks0426 result15.pngKs0426 result15-1.png

Here you can click the link below to get more use details of Arduino IDE.
https://wiki.keyestudio.com/Ks0001_keyestudio_UNO_R3_BOARD

We have listed out the key value of infrared remote control. See the figure below:
Ks0426 result15-2.png




How to Build an Infrared Remote Control Robot?


Overview:
How to built an infrared remote control robot? Think about it.
We can build a line tracking robot combined with tracking sensor and robot shield in the above project.
So in this circuit, you can combine an infrared remote control and robot shield to build an infrared remote control robot.
The principle is indeed simple. Send the button signal by infrared remote control; robot shield’s infrared receiver module receives the button signal to control the moving status of robot.


Source Code
thumb


Test Result
Send the test code to micro:bit main board, then insert the micro:bit main board into the robot shield and connect a 18650 battery; Turn the POWER switch ON.
Aimed at the infrared receiver head, press the button on the infrared remote controller, it can control the micro:bit robot go front, back, turn right or turn left and stop.

thumb

Note: during the test, the infrared remote control shall be directly facing the infrared receiver head on the robot shield.
The distance shall not exceed 18 meters.

thumb



Bluetooth Control Robot

thumb


Andriod Bluetooth Controlling Robot


Overview:

0426蓝牙.png

The micro:bit main board comes with Bluetooth module. Communicate built-in Bluetooth module with your mobile phone; then use Bluetooth APP to control the external devices connected to micro:bit main board.
The built-in Bluetooth module can support both Andriod and IOS system. But the use method is different.
In this project, you will learn how to connect the Bluetooth module in Andriod system so as to drive the robot move.


Adding Code libraries:
Note: before setting the test code, you need to add the libraries. Follow the instructions below:

Connect the micro:bit main board to your computer using a USB cable.

thumb

Open the micro:bit Software MakeCode editor https://makecode.micro:bit.org/
Click to add “New Project”, then you will see the interface below:

thumb

Then click Advanced, find the Extensions to add file.

thumb

Then click the Bluetooth.
thumb

Select Remove extensions and add Bluetooth.
thumb

Finally, you should see the Bluetooth is added well.
thumb

Then click the Extensions again, enter the library link below and search:
https://github.com/LaboratoryForPlayfulComputation/pxt-BlockyTalkyBLE-UART
thumb

Finally, you should see the library blocky Talky BLE is added successfully.
thumb


Source Code:
Right click the source code to send to micro:bit main board.
thumb


Using Bluetooth APP:

Send the above source code to the micro:bit main board; then power on the micro:bit main board Click the link to download the Bluetooth APP:
https://drive.google.com/open?id=1u_wXlpuRjcChpCcVPcIha4yWYWhefhW2

蓝牙APP.png

Installed well the Bluetooth APP, click the icon to open the APP.
Once your phone detects Bluetooth module on micro:bit main board, the APP will prompt to open the Bluetooth. Choose to open the Bluetooth. Pop up the interface below:
APP界面.png

No connecting the Bluetooth APP, Micro:bit main board will show a smile face on the LED matrix.

Then click the Bluetooth icon 蓝牙图标.png, it will pop up the micro:bit Bluetooth interface.
0426 蓝牙microbit.png

Then click 0426 蓝牙microbit 2.png to connect the micro:bit Bluetooth.

Bluetooth connected, you will see the LED matrix on the Micro:bit main board showing a heart image.

Bluetooth App functions:
0426 蓝牙microbit 3.png


Test Result:
Send well the test code to micro:bit main board; insert the micro:bit main board into robot shield; turn power switch on.
Follow the method mentioned above, connect the Bluetooth on the micro:bit main board using Bluetooth APP.
Bluetooth connected, click the icons on the APP to randomly control the micro:bit robot running.
0426 蓝牙microbit 4.png




IOS Bluetooth Wireless Programming and Control


This section will introduce how to use wireless programming and control in IOS devices (ipad/iPhone).

Use Method is follows:
Step 1: Open the App store on your ipad/iPhone.
Step 2: Search the micro:bit to download and install.

thumb

Pay close attention to:
Connect your micro:bit main board to PC; Open the micro:bit Software MakeCode editor https://makecode.micro:bit.org/, click the icon thumb, select the Project Settings and no pairing required.
thumb

thumb


Step 3: open the micro:bit interface, click Choose micro:bit.
thumb

Then click Pair a micro:bit, and click Next.
thumb

Step 4: power on the micro:bit main board, HOLD the A and B buttons, then press and release RESET button. The micro:bit main board will enter the Bluetooth pairing mode.
You should see an image showing on the LED matrix.
thumb

Step 5: copy the pattern from your micro:bit device and tap Next.
thumb thumb

Continue to tap Next to pair.
thumb thumb

OK, pairing successful!
thumb

Step 6: now go to control robot; press the Reset button on the micro:bit main board; then tap Create Code on the micro:bit APP.
thumb

Step 7: open the Microsoft MakeCode for micro:bit, click the icon thumb , select to open the Project Settings.
thumb

Then you will see the interface below. Close the option2 (JustWorks pairing...) and open option1(No Pairing Required...)
thumb thumb

Step 8: write the code
thumb

Wrote well, click the triangle icon at the bottom left to change the name; then click to save the code.
thumb

Step 9: go to the Flash interface, click the blue bar to flash code to micro:bit. Wait the process complete.
thumbthumb

OK. Flashing successful!
thumb


How to Build IOS Bluetooth Control Robot

In the previous section, you have learned the knowledge of IOS Bluetooth wireless programming and control.
Now let’s move on to build an IOS Bluetooth control robot. The method is almost the same.
We have packaged all the source code. So you can drag the code file to micro:bit makecode window to check out. Or Right click the code file to send to micro:bit main board.
thumb

Source Code:

thumb


Use Method is follows:
Step 1: Open the App store on your ipad/iPhone.
Step 2: Search the micro:bit to download and install.

thumb

Pay close attention to:
Connect your micro:bit main board to PC; Open the micro:bit Software MakeCode editor https://makecode.micro:bit.org/, click the icon thumb, select the Project Settings and no pairing required.
thumb

thumb


Step 3: open the micro:bit interface, click Choose micro:bit.
thumb

Then click Pair a micro:bit, and click Next.
thumb

Step 4: power on the micro:bit main board, HOLD the A and B buttons, then press and release RESET button. The micro:bit main board will enter the Bluetooth pairing mode.
You should see an image showing on the LED matrix.
thumb

Step 5: copy the pattern from your micro:bit device and tap Next.
thumb thumb

Continue to tap Next to pair.
thumb thumb

OK, pairing successful!
thumb

Step 6: now go to control the robot; press the reset button on the micro:bit main board; then tap Monitor and Control on the micro:bit APP.
thumb

Step 7: Tap the Add and then select the Gamepad.
thumb

And you should see the control interface shown below. Click Start to connect.
thumb

Connection successful! Click Stop to disconnect.
thumb


Test Result:
Press key A, robot goes front; Press the key B, go back; Press key C, turn left; Press key D, turn right;
Press Stop to disconnect the Bluetooth, robot will stop.
Press key 1, robot stops; Press key 2, robot stops to turn left 180° and then stop to go forward;
Press key 3, robot will turn left circle; press key 4, turn right circle.

thumb


Related Resources Link

You can download all the information needed from the link below:
https://drive.google.com/open?id=1vxESHAOWctadONe-8mImSPYi-JEEGE9g

Download the micro:bit driver:
https://drive.google.com/open?id=18g1tebO73kpHDqohhP2WWjmrWO7MvvrZ

Download the Bluetooth APP:
https://drive.google.com/open?id=1u_wXlpuRjcChpCcVPcIha4yWYWhefhW2

Download the User Guide:
https://drive.google.com/open?id=1NESb2BdathiVVst6NxrqaOW4PrFYmQNk

Download all the source code:
https://drive.google.com/open?id=1qR3848mxxGU6VxxUKncL0UGYEdawzlP6


Buy From

Aliexpress store here:New-Keyestudio-Micro-bit-Mini-Smart-Robot-Car-V2