0% found this document useful (0 votes)
35 views94 pages

IBIT Racer ActivityBookE

Uploaded by

bombiiez100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views94 pages

IBIT Racer ActivityBookE

Uploaded by

bombiiez100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 94

Programmable robot with micro:bit 1

Programmable robot
with micro:bit
Activity book

Innovative Experiment Co.,Ltd


2 Programmable robot with micro:bit

Credits
iBIT ; the robot controller board are trademarks of Innovative Experiment Co., Ltd.

iBIT robot kit, iBIT robot kit logo, INEX, and INEX logo are trademarks of Innovative
Experiment Co., Ltd.

micro:bit and micro:bit logo are trademarks of micro:bit Educational Foundation.

I2C is a registered trademark of NXP Semiconductors.

Microsoft, Windows are registered trademarks of the Microsoft Corporation.

All product and service names mentioned herein are the trademarks of their respective
owners.
Programmable robot with micro:bit 3

Contents
1 - iBIT robot kit plus introduction and part list...........................................................................5

2 - iBIT:Racer robot Assembly Insturctions.......................................................................................17

3 - About micro:bit..............................................................................................................................31

4 - Getting start coding with micro:bit......................................................................................39

5 - iBIT:Racer robot operation with iBIT Block package..........................................................51

6- iBIT:Racer robot with Line tracing activity...........................................................................71


4 Programmable robot with micro:bit
Programmable robot with micro:bit 5

Chapter 1

introduction and part list


iBIT robot kit is a micro:bit-based mobile robotic kit. It comes complete with wheels,
motors, sensors, software, documentation, etc. The iBIT controller board support the
micro:bit microcontroller. The Microsoft Programming Experience Toolkit or Microsoft PXT
Block Editor, JavaScript and Python software is recommended.

For students and teachers; this kit comes with a comprehensive set of activities
and introducing sensors and microcontrollers using the well-popular micro:bit platform.
No soldering is required so the kit is perfectly safe for the classroom. The iBIT robot kit
comes with 2 versions :

1. iBIT robot kit Lite. It includes the micro:bit and iBIT controller board. It also
includes simple sensors (touch sensors and infrared reflector sensors), DC motor
gearboxes and many mechanical parts that allow you to make an autonomous robot
suitable for learning of the Microsoft PXT Graphical programming language. This version
is most affordable for beginners in robotics.

2. iBIT robot kit Plus . It also includes all main components that are in the Lite kit
and other extra part such as the Aluminum wheels, Silicone tires, a standard mini servo
motor and extra chasis. With the Plus version, it allows users to learn more about robotics
in education as well as competition.

1.1 Part list


1. micro:bit ; the 32-bit microcontroller board with 5x5 matrix LED, compass sensor.
3-axis accellerometer sensor and Bluetooth 4.0 circuit
2. iBIT controller board for supporting the micro:bit
3. LED output board with JST cable (ZX-LED) x 2
4. RGB LED programmable board (ZX-SLED3C) x 3
5. Piezo Speaker board (ZX-SPEAKER)
6. Switch/Touch sensor with JST cable (ZX-SWITCH01) x 2
7. Infrared reflector board with JST cable (ZX-03) x 2
8. Metal micro gearbox low power with 30:1 gear ratio with IDC cable x 2
9. Mini standard servo motor (Operating voltage is 4.8 to 6Vdc)
10. Aluminum wheels 33x21 mm. diameter (x2) with Silicone tires, socket screws
and an Allen wrench
6 Programmable robot with micro:bit

11. A 3/8” plastic ball caster set


12. iBIT:Racer robot chassis
13. Metal standoffs set
14. Plastic bracket and Strip bracket set (30 and 12 pieces)
15. Nuts and Screws set
16. 4AAA battety holder with terminal plug
17. The standard microUSB cable for downloading and communication

1.2 micro:bit
micro:bit is a tiny programmable computer, designed to make learning and
teaching easy. Figure 1-1 shows the important details of micro:bit. Summary features are
as follows :

 25 individually-programmable LEDs
 2 programmable buttons
 Physical connection pins
 Light and temperature sensors
 Motion sensors (accelerometer and compass)
 Wireless Communication, via Radio and Bluetooth
 USB interface
 Main microcontroller is a 32-bit ARM Cortec M0; nRF51822 from Nordic
Semiconductor with 256KB flash memory 10,000 erase/write times and 16KB RAM. Run
with 16MHz crystal

 23 I/O with 80-pin edge connector. 1.27mm. pitch. and 5 big pads with 4mm.
pads for supporting alligator clips include P0, P1, P2, +3.3V and Ground. The figure 1-2
shows about micro:bit I/O port pin assignment. Summary are +3.3V (3 pins), GND (3 pins)
and 17 pins for I/O port.
Programmable robot with micro:bit 7

Figure 1-1 micro:bit features and components

Figure 1-2 micro:bit’s input/output pin assignment


8 Programmable robot with micro:bit

1.3 iBIT controller board


The summarized technical feature of the iBIT controller board for micro:bit is as
follows :
 80-pin edge connector for supporting micro:bit and pluggable the micro:bit
adaptor board
 Terminal block for battery connections. It supports +4.8 to +9Vdc

 A barrel jackl for external DC adaptor +5 to +9Vdc

 On-board power switch.

 +3.3Vdc switching regulator power supply circuit. Its regulates the supply
voltage for micro:bit and all components
 +6Vdc power supply circuit for servo motor output

 8-ch analog inputs with 12-bit ADC integrated circuit. Voltage input range 0
to +3.3Vdc. It supports expandable to 32 channels via I2C bus

LED power Low battery indicator


indicator (for 4AAA battery source)

DC jack input
+4.8V to +9V

Battery terminal
+4.8V to +9V

8-ch analog inputs


POWER
with 12-bit ADC
switch
resolution
micro:bit 80-pin Vin 0 to +3.3V
edge connector

Gold-plated 4mm.
pads of micro:bit
P0 to P2 pins with
+3.3V and GND
2-wire bus (I2C)
connectors

I/O connector : port 8/12 are shared DC motor output DC motor output
with Servo motor outputs header/terminal indicators

Figure 1-3 iBIT robotics controller board for micro:bit


Programmable robot with micro:bit 9

K2
Vin 7-9Vdc K3
K1 ON micro:bit I/O
Q1
Vin
FDS6675
7-9Vdc
KIA7031 40
1
S1 S7V8F3
POWER +3.3V 39 37 35 33 31 29 13 11 9 7 5 3 1
40 38 36 34 32 30 28 14 12 10 8 6 4 2

C2 +
IC1 GND
470F GND
278R06 OUT + SH RS +3V
2 1 16V GND
+Vs Vout Vin
0
C1 GND INH
470F 1
3 4 R1 +Vm
16V LED2 2
1k LOW-BAT. +3V 3 0 4 5 6 7 1 8 9 10 11 12 2 13 14 15 16 19 20 GND
1 K3B
LED1 R3 micro:bit
ON +V I/O
47k
3 13 14 15 16
RESET
R2
1 3 GND 1k
+3.3V Vout Vin
C4 2 IC2 +3.3V
C3 GND SHDN R4
100F 10k KIA7031
0.1F 16V 2 4

MOD1 +3.3V
S7V8F3 R5
4.7k K4 K5 K6 K7 K8 K9 K10
0 1 2 8 12 19 20
R6 AN0 AN1 AN2 SCL SDA
4.7k
+3.3V +Vs
14 15 12 13 9 11
+3.3V K11
SCL SDA A0 A1 GND COM 8-SERVO1
16 IC3
Vcc ADS7828 K12
REF 10 12-SERVO2
C5 AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C6
10F 1 +3.3V 2 +3.3V 3 +3.3V 4 +3.3V 5 +3.3V 6 +3.3V 7 +3.3V 8 +3.3V 0.1F
50V

s+ s+ s+ s+ s+ s+ s+ s+

K13 K14 K15 K16 K17 K18 K19 K20


SENSOR0 SENSOR1 SENSOR2 SENSOR3 SENSOR4 SENSOR5 SENSOR6 SENSOR7

+Vm
LED4 K22A
R7 IC4 MOTOR-2 MOTOR-2
4k7 TB6612FNG
+3.3V 13 12
+VM B1
14 11
Q2 15
+VM B1 10 - K22B
+

16 KRC102 PWMB PG MOTOR-2


16 BIN2 9 R10
17 PG 8
15 BIN1 B2 1k
C7 18 GND 7
19 B2 6
0.1F STB A2
+3.3V 20 Vcc 5
21 A2 4 R9
R8 AIN1 PG 1k
4k7 22 AIN2 3 - K21B
23 PG 2
+3.3V
+

PWMA A1 MOTOR-1
24 +VM 1
A1
Q3
KRC102 C8 LED3 K21A
13 C9 470F MOTOR-1 MOTOR-1
0.1F 16V
14

Figure 1-4 iBIT robotics controller board schematic


10 Programmable robot with micro:bit

 5 free I/O ports and assign to 3-pin JST connectors for interfacing with sensors
and peripherals :
- 3 Universal port support Analog input functions and Digital input/output
function; P0, P1 and P2 with gold-plated contacts.
- 2 Digital input/output function; 8 and 12 share with servo motor outputs
 I2C bus port; SCL and SDA for extension

 2 of DC motor outputs with indicators. Supports motor voltage of 4.5 to 9Vdc


1A output current. Not recommedded for Tamiya’s standard motor except the low
current model.
 2 of servo motor outputs; connect with the digital port 8 (SV1) and 12 (SV2).

 LED power and Low battery indicator

The complete schiematic of iBIT controller board is shown in the Figure 1-4.

iBIT controller board also comes with the micro:bit adaptor board. Normally user
can plug the micro:bit board directly to iBIT board with vertical direction. Additional
user possible plug the micro:bit in horizontal direction by using the adaptor board
following the Figure 1-5.

Figure 1-5 Example of pluging the micro:bit board with iBIT controller board
[Left] Vertical direction directly
[Right] Horizontal direction by using the micro:bit adaptor board
(bundled in the kit ready)
Programmable robot with micro:bit 11

1.4 Output devices features


1.4.1 Micro metal gearbox motors
This robot kit provides 30:1 ratio micro metal gearbox motors low power model
MG1-30LP with IDC connector cables and mounting part sets. Features include :

 Operating voltage is 3 to 12Vdc

 Current consumption 40mA @6Vdc and no load

 Average speed 440 round per minute (RPM) @6V and no load

 Weight is 9.5 grams

 Stall torque is 0.29 kg.cm. @6Vdc

 Attached with the mounting bracket with screw and nut set

 10 x 12 x 26 mm. (WxLxH) dimension with shaft length 10mm.

1.4.2 ZX-LED : the simple output board


This module use 8mm. diameter LED. It requires logic “1” or “high” for driving LED.
The schematic diagram is shown in the figure below.

LED1

R1
(Default = 510)

+ Q1
S

KRC102
(DTC114)
12 Programmable robot with micro:bit

1.4.3 Standard mini servo motor


The mini standard servo is ideal for robotics and basic movement projects. These
servos will allow a movement range of 0 to 180 degrees. The servo output gear shaft is
a standard Futaba configuration. Technical specifications are :

connector shaft
cable
GND (-)
+Vm
Signal STANDARD
SERVO MOTOR

Body

 Operating voltage is 4.8 to 6Vdc max.

 Speed 0 deg to 180 degree in 0.3 seconds on average.

 Weight 13.4 grams

 Torque 1.6kg-cm/21oz-inch

 Size in mm. (L x W x H) 32 x 22 x 28

1.5 Sensor module features


1.5.1 Switch module/Touch sensor (ZX-SWITCH01)

LED1 Indicator +V

R2
10k
R1
510 R3
220 DATA

Signal output
S1
GND
Switch

The switch input is used to detect collision at logic “0”. Two sets along with the
connecting cable are provided.
Programmable robot with micro:bit 13

1.5.2 ZX-03 : Infrared reflector sensor


The heart of this sensor is TCRT5000 reflective object sensor. It is designed for close
proximity infrared (IR) detection. There’s an infrared diode behind its transparent blue
window and an infrared transistor behind its black window. When the infrared emitted by
the diode reflects off a surface and returns to the black window, it strikes the infrared
transistor’s base, causing it to conduct current. The more infrared incident on the transistor’s
base, the more current it conducts. When used as an analog sensor, the ZX-03 can detect
shades of gray on paper and distances over a short range if the light in the room remains
constant.

The suitable distance from sensor to line or floor is during 3 to 8 mm. The output
voltage is during 0.1 to 3V from +3.3V suuply and digital value from12-bit A/D converter
is 800 to 4,000. Thus, ZX-03 will suitable to apply to line tracking sensor.

Signal connector

+V

OUT TCRT5000

GND 510
10k
Infrared Reflector
14 Programmable robot with micro:bit

1.5 iBIT robot kit cable information


The iBIT robot kit includes some signal cables for the interfacing between the
controller board, sensor module and the computer. They includes the JST3AA-8 cables
for interconnection to the sensor module and the standard USB-microB cable for
interfacing with the computer.

1.5.1 JST3AA-8 cable


This is an INEX standard cable, 3-wires combined with 2mm. The JST connector is
at each end. 8 inches (20cm.) in length. Used for connecting between microcontroller
board and all the sensor modules in the iBIT robot kit. The wire assignment is shown in the
diagram below.

2mm. pitch 2mm. pitch


GND
GND
S S/Data
+5V
+5V

1.5.2 Standard USB-microB cable


This is used to connect between the computer’s USB port and the micro:bit. Its
length is 1.5 metres approximation.
Programmable robot with micro:bit 15

1.6 Mechnical part features


1.6.1 Aluminum wheels and Silicone Tire set
This is good traction wheel and tires. The wheel’s inside aluminum rim is processed
at CNC lathes. Better for 2 wheeled robots. Also suitable for fast line follower robots.

These are features of the wheels :

 Weight is 22 grams.

 Wheel rim accepts 12mm, 15mm and 16mm diameter micro metal gearbox
motors. Center hole is drilled to 3mm (Which is very common shaft for miniature
gearmotors)

 It has an M4 set screw inside, so It holds motor's shaft mechanically and firmly.

The kit includes 2 pairs of the wheel and silicone tire, socket screws and an Allen
wrench.

1.6.2 Plastic ball caster set


This ball caster kit includes a black ABS housing, a 3/8 inch diameter plastic ball,
two of 3mm. thick spacers and two 2x20mm. screw sets. The total height of the ball
caster, 0.4 inch, can be increased to about 0.6 inch using the included spacers. The two
included 2x20mm. screws can be used to mount the ball caster to the robot chassis.
16 Programmable robot with micro:bit

1.6.3 Racer chassis


This chassis is made from high quality PVC plastic. It was designed suitable for
fixing the micro metal gearbox motor and the ball caster wheel. This chassis has many
3mm. holes for fixing the controller board, sensors and more mechanical parts.

1.6.4 Plastic bracket


There are 30 pieces of mixed-color bracket. They are made from PVC plastic.
They can be connected together or by using screws and 3 mm nuts in installation. There
are 3 types; Right angle, Obtuse and Straight bracket.

1.6.5 Strip bracket


They are made from plastic. Each bracket includes 3mm. hole with 5mm. pitch.
Each strip bracket can connect for lenght expansion. The set includes 4 pieces of 3
sizes; 3, 5 and 12 holes type. Total 12 pieces.
Programmable robot with micro:bit 17

1.6.6 Right-angle metal bracket


It is 7.5mm. width right-angle metal bracket. Each bracket has 3mm. hole for
inserting the screw to fix with another structures. The set includes 4 pieces of 1x2, 2x2
and 2x5 holes metal bracket.

1.6.7 Screw and Nut set


Includes 2 of 2mm. self-tapping screws, 16 of 3x8mm. M3 truss head screws, 30 of
3x10mm. M3 truss head screws, 4 of 3x15 mm. M3 truss head screws, 4 of 3x25mm. M3
screws, 30 of 3mm. M3 nuts and 4 of 3mm. washer.

1.6.8 Metal standoffs and Thumb screws


They are metal parts for supporting and fixing the chassis and any circuit board.
They are made from nikle plating metal. Includes 4 of 15mm. standoffs and 3 of 20mm.
thumb screws. Each standoffs has 3mm. thread through-hole.

1.6.9 Plastic standoffs


They are some mechanical parts for supporting the plate and sensor board. This kit
includes 4 pieces set of plastic standoff (3mm., 10mm., 15mm. and 25mm.) 4 sets
18 Programmable robot with micro:bit
Programmable robot with micro:bit  19

Chapter 2

Assembly Instructions

2.1 Overview
All parts for assembly the iBIT:Racer robot are shown in the figure 2-1.

Figure 2-1 : iBIT:Racer robot parts


20  Programmable robot with micro:bit

2.2 Assembly Instructions


(1) Prepare the wheel and tire set. It includes a pairs of 33x20mm. aluminum wheel,
silicone tires, M4 socket screws and an Allen Wrench

(2) Open the silicone tire to find the fixing hole.

(3) Tighten the socket screw into the hole by using the wrench. Then insert the
wheel to the motor shaft.
Programmable robot with micro:bit  21

(4) Tighten the screw to fix the wheel with the motor shaft. Do same for another
wheel and tire set.

(5) Fix the mounting bracket with the micro metal gearbox. Do 2 sets.

(6) Insert the mounting nuts (2mm. nut) into both fixing holes of the mounting.
22  Programmable robot with micro:bit

(7) Place the motor with bracket on the robot chassis at the position following
the photo below.

(8) Insert the mounting screws (2x20mm. screw) to fix the motor with the robot
chassis and tighten it.

(9) Fasten both motor gearboxes on the chassis.


Programmable robot with micro:bit  23

(10) String the motor cables through the trapezoid aperture and flip over the
robot chassis. The motor gearbox installation is ready.

(11) Next is ball caster assembly. Prepare the ball caster wheel part. It includes
Ball caster, 2 pieces of pad, 2 sets of the 2x20mm. screw and nut.

(12) Assembly all parts together following the illustration below.

2x20mm. screw

Ball caster body


Ball caster pad #2
Ball caster pad #1
24  Programmable robot with micro:bit

(13) Flip the robot chassis. Place the bass caster at the front.

(14) Tighten the ball caster with 2 pieces of 2mm. nuts on the top side of chassis.
Programmable robot with micro:bit  25

(15) Prepare the battery holder part set. It includes a 4AAA battery holder, 2 sets
of 2x20mm. flat head screw and nut.

(16) Place the battery holder at position of the top of robot chassis following the
photo below. Attach with the chassis by using 2 sets of 2x20mm. flat head screw and
nut.

(17) Install the IR reflector sensors. Insert the 3x15mm. screw through the ZX-03
sensor and 3mm. plastic washer. Do 2 sets.

ZX-03 sensor

sensor case
plastic washer

3x15 mm. screw


26  Programmable robot with micro:bit

(18) Flip over the robot chassis again. Attach both ZX-03 sensors at the front of the
robot chassis following the photo below by tightening the 3mm. nuts. String the sensor
cables through the trapezoid aperture.

(19) Flip the robot chassis back. Prepare the metal standoffs for fixing at all positions
following the photo.
Programmable robot with micro:bit  27

(20) Insert the standoffs on the top of the robot chassis. Tighten with 3mm. nuts
28  Programmable robot with micro:bit

(21) Place the iBIT controller board over the standoffs. Tighten with 3 of the hand
screws.

(22) For the last standoffs, tighten with a 3x8mm. screw by using the screwdriver.
Programmable robot with micro:bit  29

(23) Plug the terminal header of battery holder to the iBIT board.

(24) Plug the micro:bit to the iBIT board. Make sure plugging correct side. See the
photo for making correctly.
30  Programmable robot with micro:bit

(25) Connect all cables to the iBIT board :


(25.1) The motor cables
Left motor is connected to the Motor output -1.
Right motor is connected to the Motor output-2.
(25.2) Sensor cables
Left ZX-03 is connected to ADC0 input.
Right ZX-03 is conected to ADC1 input.

Now, the BIT:Racer robot is ready for coding and fun.


Programmable robot with micro:bit  31

Chapter 3

About micro:bit
introduction and more technical
micro:bit is a tiny programmable computer, designed to make learning and
teaching easy and fun! This chapter introduces and describe some technical information
about micro:bit. The figure 3-1 illustrate about micro:bit’s component that showing more
technical details.

Figure 3-1 Illustration of micro:bit’s component that showing more technical


details.
Most micro:bit information in this chapter was get from The micro:bit Educational
Foundation website (microbit.org)
32  Programmable robot with micro:bit

3.1 Overview
micro:bit has the following physical features:

 25 individually-programmable LEDs

 2 programmable buttons

 Physical connection pins

 Light and temperature sensors

 Motion sensors (accelerometer and compass)

 Wireless Communication, via Radio and Bluetooth

 USB interface

Let’s take a look at what these components do and discover how to code them!

3.1.1 LEDs
The micro:bit has 25 individually-
programmable LEDs, allowing you to display text,
numbers, and images. User can control LED intensity
10 steps.

3.1.2 Buttons
There are two buttons on the front of the
micro:bit (labelled A and B). You can detect when
these buttons are pressed, allowing you to trigger
code on the device.
Programmable robot with micro:bit  33

3.1.3 Input/Output Pins


There are 25 external connectors on the edge connector of the micro:bit, which
we refer to as ‘pins’. Program motors, LEDs, or other electrical components with the
pins, or connect extra sensors to control your code!

The edge connector brings out many of the GPIO circuits of the application
processor. Some of these circuits are shared with other functions of the micro:bit, but
many of these extra circuits can be re-allocated to general purpose use if some software
features are turned off. Note: the nRF51 data sheet states that GPIO pins may be in std-
drive (0.5mA) and high-drive (5mA) mode, with a maximum of 3 pins in high-drive mode at
any one time.

Rings
3 large IO rings and two large power rings, 4mm plug and crocodile clip compatible

GPIO features
19 assignable GPIO pins
2 are assigned to the on board I2C interface
6 are used for display or light sensing feature
2 are used for on board button detection
1 is reserved for an accessibility interface
19 may be assigned as digital input or digital output
19 may be assigned for up to 3 simultaneous PWM channels
19 may be assigned for 1 serial transmit and 1 serial receive channel
6 may be assigned as analog input pins with 10-bit ADC resolution (0....1023)
3 may be assigned to an optional SPI communications interface
3 may be assigned for up to 3 simultaneous touch sensing inputs

Pitch
1.27mm, 80 way double sided.

Pads
5 pads, with 4mm holes
34  Programmable robot with micro:bit

3.1.4 Light Sensor


This is fantastic features of micro:bit. Normally
LED is output devices. This is different story of LED
operation. By reversing the LEDs of the screen to
become an input, the LED screen works as a basic
light sensor, allowing you to detect ambient light.

3.1.5 Temperature Sensor


This sensor allows the micro:bit to detect the
current ambient temperature, in degrees Celsius.
Really micro:bit does not detect the ambient
temperature directly. It detects the CPU operating
temperature. Because the micro:bit is open and
CPU inside the microcontroller meet the ambient
direct. We can assume the CPU temperature as
ambient temperature around the microcontroller

3.1.6 Accelerometer
An accelerometer measures the acceleration
of the micro:bit; this component senses when the
micro:bit is moved. It can also detect other actions,
e.g. shake, tilt, and free-fall.

The main device is NXP/Freescale MMA8653FC;


3 axis accelerometer sensor. Resolution is 10-bit
Programmable robot with micro:bit  35

3.1.7 Compass
The compass detects the earth’s magnetic
field, allowing you to detect which direction the
micro:bit is facing. The compass has to be calibrated
before it can be used.

‘Calibrating’ the compass ensures the


compass results are accurate. When the calibration
begins, the micro:bit will scroll an instruction on the
display for you - either “Draw a circle” or “Tilt to fill
screen”. To calibrate the compass, just follow these
instructions and tilt the micro:bit to move the dot in
the centre of the screen around until you have
either drawn the outline of a circle, or filled up the
whole screen.

The on-board compass sensor is NXP/Freescale


MAG3110. Max update rate is 80Hz, Full scale range
is 1000T and sensitivity is 0.10T

3.1.8 Radio
The radio feature allows user to communicate
wirelessly between micro:bits. Use the radio to send
messages to other micro:bits, build multiplayer
games, and much more!

The on board 2.4GHz transciever supports a


number of other radio communications standards,
including the proprietary Nordic Gazell protocol. This
protocol provides a very simple small-packet Protocol : Nordic Gazell
broadcast radio interface between other devices Frequency band : 2.4GHz
that support this proprietary protocol, such as other Channel rate : 1Mbps or 2Mbps
micro:bit devices. The ‘radio’ interface that appears
Encryption : None
in a number of the languages on the micro:bit is built
on top of this Gazell protocol. Additionally, the Channels : 101 (0..100)
micro:bit runtime software adds a ‘group code’ to Group codes : 255
each data payload, allowing for simple user Tx power : 8 user configurable settings
managed device addressing and filtering to take from 0 (-30dbm) to 7 (+4dbm)
place.
Payload size : 32 (standard) to 255
36  Programmable robot with micro:bit

3.1.9 Bluetooth
A BLE (Bluetooth Low Energy) antenna allows
the micro:bit to send and receive Bluetooth signals.
This allows the micro:bit to wirelessly communicate
with PCs, Phones, and Tablets, so user can control
the mobile phone from micro:bit and send code
wirelessly to the target device from mobile phone!

Before using the Bluetooth Antenna user will


need to pair micro:bit with another device. Once
Stack : Bluetooth 4.1 with BLE
paired, user can send scripts wirelessly to micro:bit.
Band : 2.4GHz ISM (Industrial,
The on board 2.4GHz transciever supports Scientific and Medical)
Bluetooth communications via the Nordic S110
Channels : 50 (2MHz channels, only
SoftDevice, which provides a fully qualified 40 used (0 to 39), 3 advertising
Bluetooth low energy stack. This allows the micro:bit channels (37,38,39))
to communicate with a wide range of Bluetooth Sensitivity : -93dBm in BLE mode
devices, including smartphones and tablets. Tx Power : -20 to 4dBm in 4 dB steps
Role : GAP Peripheral
Congestion avoidance : Adaptive
Frequency Hopping
Profiles : BBC micro:bit profile

3.1.10 USB Interface


The USB interface allows user to connect the
micro:bit to computer via a micro-USB cable, which
will power the device and allow user to download
scripts onto the device.

The interface chip handles the USB


connection, and is used for flashing new code to
the micro:bit, sending and receiving serial data back
and forth to your main computer.
USB controller : NXP/Freescale
MKL26Z128VFM4
Core variant: ARM Cortex-M0+
Flash ROM : 128KB
RAM : 16KB
Speed : 16MHz
Programmable robot with micro:bit  37

3.2 About the micro:bit Processor


The nRF51 application processor is where user programs run. A single, complete
application including user code, runtime code and bluetooth stack is loaded and run
directly from on chip flash memory. All user accessible GPIO pins are provided by this
processor. There is an onboard 2.4GHz radio engine used to provide Bluetooth
capabilities via an off-chip aerial.

The main processor is Nordic nRF51822. It has Flash ROM 256KB, RAM 16KB and run
with 16MHz clock frequency.

3.3 The micro:bit Educational Foundation and


upstream communities
This website is run by the micro:bit Educational Foundation in order to document
the hardware and software that make the micro:bit work the way it does. By doing so,
we hope to encourage contributions into all of the projects that are used in order to
build the ecosystem, ultimately broadening the range of things people can invent with
a micro:bit, and making each step of invention easier.

The micro:bit Educational Foundation aims to be a ‘responsible downstream’ to


the many open source software projects that are used to build the micro:bit: much like
a good Linux distribution collates, tests, stabilises and releases combinations of many
diverse open source packages, the micro:bit Educational Foundation and the micro:bit
community present micro:bit users with a stable, tested release of all the things you
need to make the magical ‘end-to-end’ micro:bit experience.
38  Programmable robot with micro:bit
Programmable robot with micro:bit  39

Chapter 4
Getting start coding with
micro:bit
micro:bit’s coding is very easy. It can be coded from any web browser in Blocks,
Javascript, Python, Scratch and more; no software required. There are three exmple of
coding tools for micro:bit

1. JavaScript Blocks Editor


The micro:bit JavaScript Blocks editor makes it easy to program your BBC micro:bit
in Blocks and JavaScript. Powered by MakeCode. User can coding by entering to
MakeCode website here :

https://makecode.microbit.org/#
40  Programmable robot with micro:bit

2. Python Editor
Python editor is perfect for those who want to push their coding skills further. A
selection of snippets and a range of premade images and music give you a helping
hand with your code. Powered by the global Python Community.

3. Android and iOS apps


The micro:bit apps let you send code to your
micro:bit wirelessly using Bluetooth. No leads needed!

This activity book chooses coding by using Java


Script Blocks Editor. It is developed under Microsoft
Programming Experience Toolkit (PXT) project.
Programmable robot with micro:bit  41

4.1 Getting start


The JavaScript Blocks Editor is a visual, intuitive programming environment. Program
your micro:bit in Blocks or switch to JavaScript, and take full advantage of the device’s
many features, such as peer-to-peer radio and Bluetooth.

4.1.1 Preparation software


Normally the micro:bit JavaScript Blocks Editor is web-based then user must
connect to internet and access to MakeCode webpage for coding. However we can
coding by off-line or internet access not require.

(1) Firstly, access to internet. Enter to www.microbit.org. Choose Let’s Code menu.
42  Programmable robot with micro:bit

(2) At the JavaScript Blocks Editor section, click on the Let’s Code button. It redirect
to MakeCode webpage for coding at https://makecode.microbit.org/#

(3) Adding the iBIT block command package. Select Advance > Add Package
from command list on the left menu.

This is very important step. You must do firstly. iBIT block


package helps you to create the code for controlling the iBIT:Racer
easier and more powerful.
Programmable robot with micro:bit  43

(4) Type the iBIT package link following this

https://github.com/inexglobal/pxt-iBit

Then click on the search button

(5) iBIT package appears in the command list on the left menu. Try to click on the
iBIT name. All blocks are under the iBIT package will appear
44  Programmable robot with micro:bit

(6) Bookmark this webpage. Try to close web browser. Disconnect internet. Open
web browser again and open the MakeCode web page from bookmark. Now you
can coding with JavaScript Blocks Editor by offline.

4.1.2 Connect it
(1) Connect the micro:bit to the computer via a micro USB cable. Macs, PCs,
Chromebooks and Linux systems (including Raspberry Pi) are all supported.

(2) Your micro:bit will show up on your computer as a drive called ‘MICROBIT’.
Watch out though, it’s not a normal USB disk.
Programmable robot with micro:bit  45

4.1.3 Program It
(1) Using JavaScript Blocks Editor, write the first micro:bit code. Go to menu Basic
then select forever block.

(2) Drag the forever block and drop to workspace.


46  Programmable robot with micro:bit

(3) Back to Basic menu again. Select the show leds block.

(4) Drag the show leds block inside the forever block.

(5) Make the heart icon on the show leds block by clicking on any LED in the
show leds block as follows.
Programmable robot with micro:bit  47

(6) Copy the show leds block and drop under forever block. Then create another
heart pattern on the second show leds block to make it blink.

(7) 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. You can save as this
hex file to other name.
48  Programmable robot with micro:bit

(8) Once the hex file has downloaded, copy it to your micro:bit just like copying a
file to a USB drive. On Windows you can right click and choose Send To MICROBIT.
Programmable robot with micro:bit  49

(9) The micro:bit will pause and the yellow LED on the back of the micro:bit will
blink while your code is programmed. Once that’s finished the code will run
automatically.

micro:bit LED shows the flashing heart continue.


50  Programmable robot with micro:bit
Programmable robot with micro:bit 51

Chapter 5

Operation
with iBIT block package
Coding the iBIT:Racer robot is simple and easy by using the iBIT block package in
micro:bit Javascript Block editor or Microsoft PXT block editor. User can add package
following the steps in Chapter 4.

Figure 5-1 iBIT:Racer Robot connection assignment


52 Programmable robot with micro:bit

User must know some information about the hardware connection of iBIT:Racer
robot. The figure 5-1 shows the important details about connection assignment.

iBIT:Racer robot’s left motor is connected with MOTOR-1 output.

iBIT:Racer robot’s right motor is connected with MOTOR-2 output.

Left sensor is connected with ADC0 analog input.

Right sensor is connected with ADC1 analog input.

5.1 Adding iBIT block package.


This step was described in Chapter 4. However we can describe repeat.

(1) Firstly, access to internet. Enter to www.microbit.org. Choose Let’s Code menu.
Programmable robot with micro:bit 53

(2) At the JavaScript Blocks Editor section, click on the Let’s Code button. It redirect
to MakeCode webpage for coding at https://makecode.microbit.org/#

(3) Adding the iBIT block command package. Select Advance > Add Package
from command list on the left menu.

This is very important step. You must do firstly. iBIT block


package helps you to create the code for controlling the iBIT:Racer
easier and more powerful.
54 Programmable robot with micro:bit

(4) Type the iBIT package link following this

https://github.com/inexglobal/pxt-iBit

Then click on the search button

(5) iBIT package appears in the command list on the left menu. Try to click on the
iBIT name. All blocks are under the iBIT package will appear
Programmable robot with micro:bit 55

(6) Bookmark this webpage. Try to close web browser. Disconnect internet. Open
web browser again and open the MakeCode web page from bookmark. Now you
can coding with JavaScript Blocks Editor by offline.

5.2 How to make code for iBIT:Racer Robot


Coding for micro:bit of the iBIT:Racer robot is easy. There are only 4 main steps
following the figure 5-2.

Step 1 - Go to https://makecode.microbit.org or working off-line by adding


bookmark in the web browser.

Step 2 - Drag and Drop the command block to create the code.

Step 3 - Connect the micro:bit to computer’s USB port.

Step 4 - Download and save the .HEX file to micro:bit.


56 Programmable robot with micro:bit

Figure 5-2 How to make code for micro:bit of the iBIT:Racer Robot
Programmable robot with micro:bit 57

5.3 iBIT block package


Figure 5-3 shows the overview all command blocks of iBIT package.

There are 4 groups as follows :

1. Movement control blocks with one motor

2. Movement control blocks with two motors

3. Servo motor control blocks

4. Sensor reading blocks

Figure 5-3 iBIT command block package for iBIT:Racer robot


58 Programmable robot with micro:bit

5.4 Movement control blocks with one motor


There is one block as follows :

This block support each motor outputs with forward / backward direction and
set the speed from 0 to 100% like these :
Programmable robot with micro:bit 59

5.5 Movement control blocks with two motors.


There are many function blocks for controlling the robot movement. They include :

1. Straight moving direction (forward / backward)

2. Turning direction (turn left / turn right)

3. Spin moving direction (spin left / spin right)

5.5.1 Straight direction moving blocks

This block support 2 motor outputs in same time with forward / backward direction
and set the speed from 0 to 100% and stop moving like these :
60 Programmable robot with micro:bit

5.5.2 Turning direction blocks

The pivot point of robot moving is at the center point of the wheel of the motor
which is off. The robot will turn with speed value until the time that user set.

These blocks control 2 motor outputs in same time with turn left / turn right and set
the speed from 0 to 100% like these :
Programmable robot with micro:bit 61
62 Programmable robot with micro:bit

5.5.3 Spin moving direction blocks

The pivot point of robot moving is at the center point of the robot between both
motors. The robot will turn with speed value until the time that user set.

These blocks control 2 motor outputs in same time with spin left / spin right and set
the speed from 0 to 100% like these :
Programmable robot with micro:bit 63
64 Programmable robot with micro:bit

5.6 Servo motor control blocks


There are 2 blocks for control the servo motor operation.

1. Servo

This block is used to control the movement of servo motor’s shaft position. User
could be select the servo motor output channel and moving angle from 0 to 180 degree.

2. ServoStop

This block is just one operation. It stops the operation of the selected servo motor
output.

5.7 Sensor reading blocks


There is only one block for reading the analog inputs.

User can select the analog input 0 to 7 for reading the sensor values.
Programmable robot with micro:bit 65

5.8 iBIT:Racer robot movement example


This topic has 2 examples about how to control the robot’s movement.

5.8.1 Example-1
(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.

(4) Place the robot on the floor. Turn on


the POWER switch of the iBIT:Racer robot.

micro:bit shows icon X and the robot


does not move.

(5) Press button-A of the micro:bit. Observe


the robot operation.

micro:bit shows icon then iBIT:Racer


robot moves forward with 50% power speed
around 1.5 seconds and stop.
66 Programmable robot with micro:bit

5.8.2 Example-2
(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.

(4) Place the robot on the floor. Turn on the POWER switch of the iBIT:Racer robot.

micro:bit shows icon X and the robot does not move.

(5) Press button-A of the micro:bit. Observe the robot operation.

micro:bit shows icon then iBIT:Racer robot continue to moves forward with
40% power speed around 1 seconds and spin left 0.3 second with 40% power speed.
Programmable robot with micro:bit 67

5.9 Servo motor control example


This topic demonstrates the servo motor position control.

(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.

(4) Connect a servo motor to Servo Output-1. Insert the servo motor’s horn. Fix it
by tightening the servo motor’s screw.

(5) Turn on the POWER switch of the


iBIT:Racer robot.

(6) Press button-A of micro:bit then


observe the servo motor operation.

Servo motor drive its shaft and


horn to 150 degree angle position from
starting point.

(7) Press button-B of the micro:bit.


Observe the servo motor operation.

Servo motor drive its shaft and


horn to 10 degree angle position from
starting point.

Caution :

Do not set the angle value down to


0 and reach to 180 for preventing the servo
motor damage.
Connect a servo motor
with SERVO1 port
68 Programmable robot with micro:bit

5.10 Reading sensor example


This topic demonstrates hwo to reading the analog sensor value from iBIT’s analog
inputs.

(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.

(4) Turn on the POWER switch of the iBIT:Racer robot.

(5) Place the robot on the white area.

(6) Press button-A of micro:bit then observe the micro:bit LED operation.

Now micro:bit reads the sensor’s value from analog input ADC0 and shows
on its LED display. The sensor data from detecting the white surface are high. The value
is during more than 2000.
Programmable robot with micro:bit  69

(7) Press button-B of the micro:bit. then observe the micro:bit LED operation again.

micro:bit reads the sensor’s value from analog input ADC1 and shows on its
LED display.

(8) Stick the black tape on the floor. Place the robot by the sensor position must
over the black tape.

(9) Press button-A of micro:bit then observe the micro:bit LED operation.

micro:bit reads the sensor’s value from analog input ADC0 and shows on its
LED display. The value must low because the sensor detects the black surface. It is
during 0 to 4095. Normally the black surface will be detect data lower 1000

(10) Press button-B of micro:bit. then observe the micro:bit LED operation again.

micro:bit reads the sensor’s value from analog input ADC1 and shows on its
LED display.

User can use these same steps for the Line tracing robot example in the next
chapter.
70 Programmable robot with micro:bit
Programmable robot with micro:bit 71

Chapter 6

with Line Tracing Activity

The most popular of the education robot activity and learning is Line tracing robot.
iBIT:Racer robot also support and has good performance about this activity. This chapter
describes about how to make code for micro:bit robot to detect the black line and
white surface for making the simple line tracing robot.

6.1 Reading sensor value to set the reference


point
Refer the last topic of Chapter 5, we introduce about how to use the ZX-03 IR
reflector sensor of iBIT:Racer robot to read the white surface and black line value. We
can describe again for doing the activity continue.

Purpose :
1. Press button-A for starting to read the sensor value from ADC0 input to shows
on micro:bit’s LED display. The sensor at ADC0 is the Left IR reflector sensor of iBIT:Racer
robot.

2. Press button-B for starting to read the sensor value from ADC1 input to shows
on micro:bit’s LED display. The sensor at ADC1 is the Right IR reflector sensor of iBIT:Racer
robot.

3. Record all values for calculating the reference value.

Procedure :
(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.
72 Programmable robot with micro:bit

(4) Turn on the POWER switch of the iBIT:Racer robot.

(5) First, read value from the white area. Place the robot on the white area.

(5.1) Press button-A of micro:bit then


observe the micro:bit LED operation.

Now micro:bit reads the sensor’s


value from analog input ADC0 and shows on
its LED display and record it. The sensor data
from detecting the white surface are high.
The value is during more than 2000.

(5.2) Prss button-B of the micro:bit.


then observe the micro:bit LED operation
again.

micro:bit reads the sensor’s value


from analog input ADC1 and shows on its LED
display and record it.

(6) Next, read value from the black line. Stick the black tape on the floor.
Place the robot by the sensor position must over the black tape.

(6.1) Press button-A of micro:bit then


observe the micro:bit LED operation.

micro:bit reads the sensor’s value


from analog input ADC0 and shows on its LED
display and record it. The value must low
because the sensor det ects the black
surface. It is during 0 to 4095. Normally the
black surface will be detect data lower 1000

(6.2) Press button-B of micro:bit. then


observe the micro:bit LED operation again.

micro:bit reads the sensor’s value


from analog input ADC1 and shows on its LED
display and record it.

(7) Get the white area and black line value to calculate the reference value.

For example, the white area value is 2500. The black line value is 500. The
reference value is (the white area value + The black line value) / 2. Result is (2500+500)/
2 = 1500. Finally we get the example reference value of the black line detection is 1500.
Programmable robot with micro:bit 73

6.2 Black line detection


This activity demonstrates the black line detection by reading the Left IR reflector
sensor and compare with the reference value. Result is shown by LED display of the
micro:bit.

Procedure :
(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.

(4) Turn on the POWER switch of the iBIT:Racer robot.

(5) Place the robot over the white surface. See the detection result from micro:bit
LED display.

The display shows SAD icon.

Because the sensor value is more than the


reference value (left > 1500).
74 Programmable robot with micro:bit

(6) Place the robot over the black line. See the detection result from micro:bit display.

The display shows HAPPY icon

Because the sensor value is less than the


reference value (left < 1500).

How to make a variable in Microsoft PXT block editor


(1) At the main window of Microsoft PXT block editor, click on the Variable in the
left menu. The block of variable will appear following the screen short below. Click
on the Make a Variable block.

(2) The dialog box for setting the variable name is appeared. For example, type
left word for create the variable name is left. Then click on the OK button to confirm.
Programmable robot with micro:bit 75

(3) Back to main window, in the Variable block list has a new variable block. It
is left block.

(4) Drag and drop the on the workspace.

(5) Change the variable by clicking on the variable name and select the target
variable. This is left then the block will be change the variable name to left.
76 Programmable robot with micro:bit

Learn about condition and comparison block


Most operation of the code is checking and comparison data. The Microsoft
PXT block editor also provides the condition and comparison blocks. These are short
tutorial.

At the main window of Microsoft PXT block editor, click on the Logic list from a
block category on the left hand side of the page. The block of Logic will appear
following the screen short below.

1. Checking condition by if…then block

If the condition is true, execute the command in the then block

User can change the if…then block to if…else…if as follows :


Programmable robot with micro:bit 77

(1.1) Drag and drop the if…then block on the workspace

(1.2) Click on the setting button of the if block

(1.3) Drag and drop the else…if block to connect the if block.
78 Programmable robot with micro:bit

(1.4) Drag and drop the else block to connect the else…if block.

(1.5) Click on the setting button of the if block again to finish.

(1.6) If you want to loop checking condition, select to Basic block category then
drag and drop the forever block to cover all if blocks following the screen short below.
Programmable robot with micro:bit 79

Operation of if…else…if block could be describe as follows :

(a) Check the first condition. If false, check next condition of else…if block

(b) If condition still is false, code will execute the command at the ending
else block.

2. Boolean operator and Comparison


2.1 Boolean Operator
A Boolean has one of two possible values: True and False.

or “1”

or “0”

2.2 Boolean logical operator


Boolean (logical) operators (and, or, not) take Boolean inputs and yields a
Boolean value.

A and B evaluates to true if-and-only-if both A and B are true:

 false and false = false

 false and true = false

 true and false = false

 true and true = true


80 Programmable robot with micro:bit

A or B evaluates to true if-and-only-if either A is true or B is true:

 false or false = false

 false or true = true

 true or false = true

 true or true = true

not A evaluates to the opposite (negation) of A:

 not false = true

 not true = false

2.3 Comparison block

There are six blocks represent comparison operators that yield a Boolean value :

equal

not equal

less than

more than

Less than or equal

more than or equal


Programmable robot with micro:bit 81

6.3 Black line detection with 2 sensors


This activity demonstrates the black line detection by reading both IR reflector
sensors; Left and Right then compare with the reference value. Result is shown on LED
display of the micro:bit.

Procedure :
(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.


(3) Download the code into micro:bit. Disconnect the microUSB cable.
(4) Turn on the POWER switch of the iBIT:Racer robot.
(5) Place the robot over the white surface. See the result from micro:bit LED display.

The display shows SAD icon.

Because the both sensor values are more than the


reference value (left > 1500 and right > 1500).

(6) Place the robot over the black line. See the result from micro:bit LED display.

The display shows HAPPY icon.

Because the both sensor values are less than the


reference value (left < 1500 and right < 1500).
82 Programmable robot with micro:bit

6.4 Robot finds the black line


This activity demonstrates the robot moves forward to finds the black line. It will
stop immediately after both sensors detect the black line together.

Procedure :
(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit. Disconnect the microUSB cable.

(4) Turn on the POWER switch of the iBIT:Racer robot.

(5) Stick the black line far from the robot’s start point about 1 metre.

(6) Place the robot at the start point. Press the buton-A. Observe the robot’s
operation.

iBIT:Racer robot moves forward with 50% speed. It moves continue until its
both sensors detect the black line. The robot will stop immediately.
Programmable robot with micro:bit 83

6.5 Simple line tracing robot


There are 4 scenarios of the line tracing robot operation.

1. Both sensors detect the white 2. Only the Left sensor detects
surface. the black line
Result : Robot moves forward over the Result : Robot spins left until both sensors
black line. meet the white surface.

3. Only the Right sensor detects 4. Both sensors detect the black line
the black line Result : Still moves forward over the black
Result : Robot spins right until both sensors line or Stop or Turn left or Turn right depend
meet the white surface. on mission.
84 Programmable robot with micro:bit

Procedure :
(1) Create the program following the block code below.

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.
Programmable robot with micro:bit 85

(4) Make the simple black line field following the illustration below. The white
surface area is 90 x 60 cm. and black line width is 1 inches (2.5 cm.)

(5) Place the robot at the start point and over the black line.

(6) Turn on the POWER switch of the iBIT:Racer robot.

(7) Press the buton-A. Observe the robot’s operation.

iBIT:Racer robot moves along the black line continue. It is possible that the
robot moves out of the line. You can improve the precision by editing the program with
adjusting the sensor reference value and adjust to the position of both infrared reflector
sensors.

When the robot moves over the crossing line, it still moves forward pass the
crossing line.
(8) Try to increase the movement speed to find the maximum speed that the robot
still move along the line completely and not move out from the line.
86 Programmable robot with micro:bit

6.6 How to make function for Line Tracing Robot


Function is the small program that contains some command block. It helps the
code minimal and shorter.

(1) Select block category Advanced > Functions then select Make a Function.

(2) Set the function name. For exmple is myFunction.

(3) The block “myFunction” is appeared.

(4) Set the command block for this function.


Programmable robot with micro:bit 87

(5) The created function will add into the menu Function automatically.

(6) Users and developers can use the new function for their code.
88 Programmable robot with micro:bit

6.7 Create line tracing function


From the simple line tracing robot topic 6.5, we can make the better operation
with better code by making function.

There are 2 functions for this activity.

1. Cross_Stop - The operation of this function is looping to check both sensors status
and try to control the robot moving along the black line at all times. If the robot detects
the crossing line, it stops immediately.
Programmable robot with micro:bit 89

2. Cross_Left - The operation of this function is looping to check both sensors status
and try to control the robot moving along the black line at all times. If the robot detects
the crossing line, it spins left to change the moving path to left.

Robot spins left until


3 both sensors detect
the white area.

2
Both IR Reflector
sensors detect
Robot moves forward the black line.
4 along the black line
continue.

1
Operation of the
Move forward along
Cross_Left function the black line.
90 Programmable robot with micro:bit

Cross_Left function
for iBIT:Racer robot

From creating 2 functions for tracing the black line, you can make the new code
for improving the line tracing robot. The next activity is making the smarter line tracing
robot. It can move along the black line and spins left when detect the first crossing line.
Next, it still move along the line and stop when detect the second crossing line.
Programmable robot with micro:bit 91

Procedure :
(1) Create the program following the block code below.
92 Programmable robot with micro:bit

(2) Connect the iBIT:Racer robot with computer’s USB port.

(3) Download the code into micro:bit of the iBIT:Racer robot. Disconnect the
microUSB cable.

(4) Make the black line arena depend on your design and add 2 crossing lines or
junctions.

(5) Place the robot at the start point and over the black line.

(6) Turn on the POWER switch of the iBIT:Racer robot.

(7) Press the buton-A. Observe the robot’s operation.

iBIT:Racer robot moves along the black line continue. It spins left to change
direction after detects the first junction then moves straight along the line and stops at
the next junction.

Robot spins left until


3 both sensors detect
the white area.

2
Both IR Reflector
sensors detect
the firt junction.
4
Robot moves forward
along the black line
continue until detect
the second junction. 1
It stops immediatly.
Move forward along
the black line.

You might also like