• Build logs, Tutorials and Hacks

    Tuesday, October 25, 2016

    BBC Microbit Line Follower Robot Project

    The BBC microbit is a simple development board for children to learn programming with and has been distributed to schools in the UK free of cost. You can buy the BBC micro:bit individually or in kit form with basic add ons from Kitronics in the UK.

    Introduction 


    It has been developed by the partnership of a long list of organisations including Microsoft, Element14, Nordic, NXP and many more. (Click here for the wikipedia link)

    The intended audience is school children and there are four official ways to write programs for the BBC Micro Bit. They are.

    • CodeKingdoms, using JavaScript;
    • Microsoft Block Editor, based on Blockly;
    • Microsoft TouchDevelop;
    • MicroPython.

    In addition to these, it is possible to really go deep with mBed at mbed.org for access to the underlying runtime and system code. For the most part, the TouchDevelop Editor from Microsoft is a good balance between programming language and user friendly IDE.

    Getting Started


    Element14 was kind enough to provide me with one of these boards and I though I would do something with the board beyond the blinking LED. So the simplest mechanical project I could think of was a simple line follower robot. The objective is to have a machine follow a line- thats it! In part one, I start with introducing the BBC Micro bit and then making a small circuit that can be used to detect a black line on a white flat sheet. This is accomplished using some IR LEDs and photodiodes.

    The Video

    We go on ahead and write a small piece of code to read the sensors and then display the movement direction on the matrix display. Here is the video for a more in detail lesson.



    Moving On

    Next, we go through the concept of a motor driver, the basic circuit and controlling DC motors with the BBC microbit. We then move to add the motors to a chassis and then write the basic routine to make the robot follow a simple line.

    More Video


    Here is a video tutorial and demo video for the project part 2




    The Motor Driver


    The L293D is a dedicated motor driving chip with 4 half H-bridges or two full H-Bridges which can be employed to control the direction two connected motors. You may choose to make an H-Bridge using transistors or even MOSFETs on a strip board etc but the single chip solution is simpler and quicker. The pin diagram and connection diagram for the L293D is shown below.



    The GPIOs in the BBC Micro:bit can be used to set the speed and direction of the motors however for this exercise, we will only be interested in modifying the direction of the motors. Since the GPIOs available on the breakout board also include the ones used for onboard peripherals such as the matrix display, we must select the ones that are unused. Take a look at the pinout diagram below. We need four IOs out of which two are used for direction and two are used for speed or turning the motors ON and OFF.



    Forming a chassis


    After connecting the motor driver and motors, we need to put everything together along with a chassis, wheels and our sensor board. I have made a simple chassis, but you can create something more elaborate and used different parts according to preference. The sky is the limit. Add batteries and we are good.

    Write the program


    We will continue using touch develop to make the program and i order to make the decision to turn right or left or move straight, we will add an IF-THEN-ELSE ladder within the loop we created the last time. The program can be downloaded as a file using the link provided at the bottom of this page. Compile the code and upload the hex file to the BBC Micro:bit.

    Create a track and test


    In order to follow a line, we need a line for which we use some black water colours and a white paper sheet. Draw a simple circle initially to test out the functionality. Make sure that the line is not too thick else the sensor will have problems detecting turns and will get stuck easily. We just need the line to thick enough that it is detected by each of the sensors individually.
    Test her out.

    To support me and my projects, please like and subscribe and leave your questions and comments in the youtube video or comments below.

    Thanks and happy hacking.

    No comments:

    Post a Comment