Exploring Robotics with the motor:bit and BBC micro:bit – Use Your Andriod Phone As A Remote Control

Exploring Robotics with the motor:bit and BBC micro:bit – Use Your Andriod Phone As A Remote Control

Introduction – In this series of tutorials so far, we’ve looked briefly at the motor:bit STEM Education Robot for the BBC micro:bit including the different capabilities of the motor:bit STEM Education Robot. We explored the capability of the motor:bit main board, learned more about the line sensor module for the motor:bit STEM Education robot, learned about the ultrasonic module for the motor:bit STEM Education robot, connected up all of the different bits that make up the motor:bit STEM Education robot and programmed the motor:bit robot to follow a line. We then moved on and programmed the motor:bit STEM Education robot to detect obstacles and navigate around them and learned howto make use of the radio capability built into the micro:bit to broadcast and receive signals for purposes of creating a smart remote control. In this tutorial we will use the Bluetooth protocol and program the micro:bit so as to control the motor:bit STEM Education robot from an Andriod phone.

This tutorial builds on all of the learning we’ve gained so far. If you’ve skipped the earlier tutorials we would highly recommend you go back, read through and perform each of the tutorials provided. Please note that it’s possible to control the motor:bit STEM education robot over Bluetooth from an IOS phone, however our focus for this tutorial will just be Bluetooth control through Android.

About the motor:bit STEM Education Robot – The Motor:bit STEM education robot is a DIY (Do It Yourself) robot based on the highly popular BBC micro:bit. The Motor:bit STEM education robot is designed to get kids (12 and older) introduced to the world of coding, electronics and robotics. The Motor:bit STEM education robot is designed from ground up to be an easy to easy to work with, easy to assemble robot and simply built with the aim of giving educators, parents and kids a great opportunity to get a taste of robotics, electronics and coding.

motor:bit STEM Education Robot for the BBC micro:bit

The Motor:bit is really easy to assemble and can be put together in less than an hour. We would recommend the Motor:bit STEM education robot to kids and adults who are willing to put in some effort to put together their robot and take on a small maker challenge assembling the robot from its different components. So if you are keen to introduce your child to the world of STEM and are keen to get them coding, introduced to the world of robotics using the micro:bit the Motor:bit is for you. Overall the Motor:bit STEM education robot is a great way to get started with the basics of coding and robotics using a flexible, affordable and easy to work with robotic platform.

If you haven’t read the initial article in this series please head over and check out –

  1. Exploring robotics with the motor:bit STEM Education Robot for the BBC micro:bit – Introduction
  2. Exploring robotics with the motor:bit STEM Education Robot for the BBC micro:bit – Diving into the capabilities of the motor:bit main board
  3. Exploring robotics with the motor:bit STEM Education Robot for the BBC micro:bit – Learning to use Line Sensors
  4. Exploring robotics with the motor:bit STEM Education Robot for the BBC micro:bit – Learning to keep distance (Learning to use ultrasonic sensors with the motor:bit)
  5. Exploring Robotics with the motor:bit and BBC micro:bit – Line Following Challenge
  6. Exploring Robotics with the motor:bit and BBC micro:bit – Avoiding Obstacles
  7. Exploring Robotics with the motor:bit and the BBC micro:bit – Remote Control
  8. Exploring Robotics with the motor:bit and the BBC micro:bit – Use Your Andriod Phone as a Remote Control (This tutorial)

If you are interested in purchasing the motor:bit STEM Education Robot for the BBC micro:bit then head over to OzToyLib and grab one now.

BBC micro:bit and the on-board Radio – The BBC micro:bit has an inbuilt Bluetooth Low Energy (BLE) radio which can be used for short range communication. Bluetooth was designed for short range communication between devices while wireless (or Wi-Fi which we are quite used to) was designed for longer range communication between devices. It’s this Bluetooth radio functionality that we’ll be exploring in this article. With Bluetooth functionality enabled we can pair up the BBC micro:bit with any other Bluetooth device (in our case an Android Cell phone) and control the motor:bit STEM Education robot from our cell phone.

For purposes of this tutorial we will make use of the bitty controller. The bitty controller is an application for the Android phone developed by bitty software. You can read more about the bitty controller at – http://www.bittysoftware.com.

The bitty controller lets you remote control a Bluetooth connected device which uses a micro-controller or computer like a BBC micro:bit, Arduino or Raspberry Pi. It provides a choice of user interfaces including several digital switches for switching things and and off, a dual d-pad controller, an analog touchpad for fine control and an enhanced UI which includes support for up to 5 sensors and has an extra button.

The Bitty controller software needs to be purchased from the Google Play store. Please speak with your parents and get them to purchase the application for you.

BBC micro:bit can communicate over radio and Bluetooth

Let’s now dive some code and implement remote control capability for our robot so that we can control our motor:bit STEM Education robot using the bitty controller on the Android phone.

Download the software : Let’s now download the software for our Android phone. Head over to the Google Play store and purchase the application.

Bitty software from the Google Play Store

Setup Bluetooth : To activate the Bluetooth on our BBC micro:bit, we will need to press button “A+B” simultaneously and then press reset button. The BBC micro:bit screen will then display PAIRING MODE!and a special character. This character is unique to each micro:bit. Do note that this is the special identifier for Bluetooth for your BBC micro:bit.

Once paired successfully with your Android or IOS device, your micro:bit screen will display a “√”(a tick).

Load some custom packages using Makecode – So let’s open up a browser and head over to BBC MakeCode for micro:bit https://makecode.microbit.org and load up the programming interface. Once you have MakeCode open head over to the “Advanced” section. We’ll now add the “motor:bit” module from the Advanced options on the BBC Makecode interface. See image below for details –

adding the motorbit library within makecode
Add custom package within BBC makecode

Let’s now add the following package “motor:bit” as shown below. You will also need to search and add the “bluetooth” package for your BBC micro:bit as shown below.You will have to search for the package “motor:bit” within the Advanced option which then imports the relevant libraries into your program.

Bluetooth package for micro:bit
Choose the motor:bit package for the BBC micro:bit from Elecfreaks

Let’s write some code – Open up your makecode block editor and create the blocks shown below.

  1. At startup the micro:bit will display “EF-motorbit”
  2. When we are connected via bluetooth the micro:bit will display “T”
  3. When disconnected the micro:bit will display “F”

For purposes of safe operations we set speed to 0 in each of the cases.

Code block 1

Set event source block and name it MES_DPAD_CONTROLLER_ID, which is the joystick controlling panel of the APP. Name the event value MICROBIT_EVT_ANY so that it can obtain all event information. If the event value is MES_DPAD_BUTTON_A_DOWN, we can know from the event table above that the event is the left top circle button is pressed. Thus, the operation status is 1 (move forward). At the same time, set both motors run at its full speed to make the car move forward. If the event value is MES_DPAD_BUTTON_A_UP, we know from the event table above that the left top circle button is released. Thus, the operation status is 0 (stop). At the same time, set the speed of both motors to 0 and the car stops. See the image below for the code block.

Code block 2

Create a variable and name is flag, which stands for the car movement status. When flage is 1, it means the car is moving forward. If the event value is MES_DPAD_BUTTON_3_DOWN, we can known from the table above that the right square button is pressed. Thus, the car will turn right. If the event value is MES_DPAD_BUTTON_4_DOWN when flag is 1, we can know from the table above that the left square button is pressed. Thus, the car will turn left. If none of the above two situations happened when flag is 1, then set the speed of both motors to 100 and the car will move forward at its full speed. See code below for details.

Code block 3

Here’s the entire code block for the BBC micro:bit connected to the motor:bit STEM Education robot as seen within the BBC makecode editor. See code below for details.

Combined code block

Load up the entire code block above onto the BBC micro:bit housed on the motor:bit STEM Education robot. Power up the motor:bit STEM Education robot and then use the bitty controller application to scan for micro:bit devices in the room.

Scan for a BBC micro:bit using the bitty controller app
Use the controls to move your robot around

Have fun!!!!!

Testing things out – Set your robot out on a flat surface, pair up the micro:bit with your Android phone and use the Bitty controller to navigate the robot around the room.

Conclusion – If you’ve followed through each of the tutorials in this series you would have by now introduced yourself to the basics of robotics. You would have learned about the motor:bit main board used to build the motor:bit STEM Education robot, learned about line sensors, learned about ultrasonic sensors, coded the robot to successfully move around a track, given your robot the ability to spot obstacles and navigate around it and finally learned how to control your robot remotely both over radio and bluetooth. Give yourself a pat on the back for having come this far. Very well done!!!!

For more tutorials please do check out the development track at KidzCanCode.com for detailed tutorials on the motor:bit STEM Education Robot for the BBC micro:bit. If you are looking to purchase the motor:bit STEM Education Robot head over to the store at <OzToyLib> and check it out.

About BBC micro:bit – The Micro Bit (also referred to as BBC Micro Bit, is an ARM-based embedded system designed by the BBC for use in computer education in the UK. The board is 4 cm × 5 cm and has an ARM Cortex-M0 processor, accelerometer and magnetometer sensors, Bluetooth and USB connectivity, a display consisting of 25 LEDs, two programmable buttons, and can be powered by either USB or an external battery pack.

BBC micro:bit

The device inputs and outputs are through five ring connectors that are part of the 23-pin edge connector at the bottom of the board. The micro:bit can be programmed using the Microsoft Block code program editor which is similar to the block based language Scratch ideal for 7-12 year olds. The micro:bit can also be programmed using the Makecode editor in Javascript and Python which allows for older kids to learn the Javascript and Python programming language using the micro:bit.

Explore our FREE coding, electronics and robotics resources for the BBC micro:bit at www.KidzCanCode.com – <Link>. Hopefully you have enjoyed the post. If you have any questions, comments or suggestions for future tutorials drop us a note at – learning at hack2 dot live.

FREE STEM learning at KidzCanCode – At KidzCanCode.com we offer FREE access to various STEM (Science, Engineering, Technology, Math) development courses at KidzCanCode.com. At KidzCanCode.com you will find courses on Scratch, BBC Micro:Bit, Raspberry Pi, Arduino, 3D modelling, Robotics and Electronics.

If you are looking for a BBC micro:bit, Arduino, Raspberry Pi, starter kits, electronics kits, robotics kits including other STEM learning kits we would recommend you drop by our online store here – <OzToyLib>.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments