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 here[LINK}
In the first part, we studied how to detect a simple line using the BBC microbic and a simple circuit using some jellybean parts. In this part, 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.
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.
Let me know what you think in the comments section and give a like and subscribe to the youtube channel for more.