That project was inspired by my students who like Arduino boards, but afraid of the micro:bit board and think that micro:bit is not so powerful to develop a robotic car! Please see what I did using just one micro:bit board and simple electronics!
1. ChassisFirst, choose a chassis for your robotic car. You can choose any chassis you want, I recommend 2 wheel-drive car. They are very cheap. I use more resistant and firm metal chassis from my Max:Bot DFRobot robotic car. Unfortunately, they don't sell robotic chassis separately, so that variant will be more expensive because their Ready-To-Run robot costs more than 100$. Here is a link: https://www.dfrobot.com/product-1790.html
After you have a chassis, let's make an electronics part for motors. You need a motor driver, I prefer to use L298N motor driver. It is easy to maintain and program, but to make it work you need to use a lot of GPIO on your board (2 PWM pins, 4 digital output pins).
For your reference please see my first project (4WD Arduino Robot Car), motors installation parts are absolutely the same. https://www.hackster.io/maxxlife/arduino-4wd-car-cf5fd0
You must connect the RED wire of the battery (+) to the +12V port on the motor driver (show on the picture above). I recommend installing a switch for the battery.
The red wire is connected like this on the picture below.
For the battery, you can use 4AA or 5AA battery case with 4AA or 5AA batteries (total 6V and 7.5V).
For my case I use Li-Po 2S battery (7.4V), high current means better performance of the robot, but you need to use a special charger for it and voltage meter.
For the micro:bit's battery uses special accessory -2AAA battery case with switch. Choose a case with a built-in switch for easy maintenance.
That is how to connect it to micro:bit.
You can choose any switch you want to make it possible easily turn on and turn off motors of the robot.
I made a common electronic design which I use in my robotics projects. You can also try to create something new. Black plug I will not use in that project (it was designed to power-up an Arduino Uno board). Blue is the switch. Black wires are going to be connected to GND port, and red wire will be connected to the +12V port on the motor driver.
Red T-plug is used to connect a battery. Different batteries have different connectors, to my mind, T-plug connector is the best one. You can easily remove discharged battery and replace it with a fresh one.
Now connect micro:bit to an expansion board. As you can see micro:bit doesn't have any pins like Arduino Uno board to which you can insert wires, that why expansion board is necessary. Insert that expansion into a breadboard.
On the expansion board, you can see pins P11, P12, P13, P14, P15, P16. That pins will control our motor driver. P11 and P16 will be used for PWM (speed control of the left and right motor), and others will be used for control of the rotation direction.
Motor driver has outputs which named ENA, IN1, IN2, IN3, IN4, ENB (on the motor driver's PCB board each pin has a printed name). This pins must be connected to the proper outputs on the micro:bit board.
Connect using male-female wire ENA motor driver's pin to P11 pin on the expansion board, and follow the same procedure for each pin.
ENA->P11 IN1->P12 IN2->P13 IN3->P14 IN4->P15 ENB->P16
Take two line sensors TCRT5000. It is digital, means output 1 (HIGH) for black line detection and output 0 (LOW) for white surface detection.
Using male-female wires connect sensors to the correct pins on the expansion board. Also use two wires for 3.3V and GND pins of the micro:bit, connect wires from them to the breadboard. It will increase the number of 3.3V and GND pins which can power-up new sensors or servos.
Left sensor OUT -> P1 VCC (Red wire) -> 3.3V GND (black wire) -> GND
Right sensor OUT -> P20 VCC (Red wire) -> 3.3V GND (black wire) -> GND
On the photo of my robot, you can see 3 line sensors, but robot works well even with 2 line sensors. A sensor in the middle is too close to left and right, it creates a disturbance for them. Note about that, if you want to use a lot of line sensors like that one, and mounted them too close to each other.
Middle line sensor I don't use in that project, just forgot to remove it.
Now is time to connect Sharp infrared distance sensor to the micro:bit. That sensor has an analog output, it means that output voltage changes according to the measured distance. Datasheet about that sensor you can find there: https://www.pololu.com/file/0J156/gp2y0a02yk_e.pdf
Standard wire for that sensor doesn't have male connectors for the breadboard, make them by yourself.
Buy that type of the male connector and connect them to the wires.
Or you can cut male wires like this and solder to the sensor's wire.
When wires are prepared, you can connect it to the breadboard.
OUT -> P0 VCC (Red wire) -> 3.3V GND (black wire) -> GND
Pan-tilt mechanism is necessary to rotate a distance sensor mounted on it to scan surroundings for the obstacles. I use a 3D-printed one, unfortunately, I don't have a 3D model for you to share. Servos are very small 9G model (or SG90), it is possible to power-up them directly from the micro:bit power source. I use only one pan-servo to rotate, tilt-servo is not used in my project and is not connected to the power source.
You can buy a plastic one and modify by yourself.
Connect pan-servo using male-male wires.
OUT -> P2 VCC (Red wire) -> 3.3V GND (black wire) -> GND
Of course, you need to mount all sensors and pan-tilt mechanism on the robot's chassis. Improve your mechanical construction and continue with the programming of the robot.
Download code archive with MakeCode file, unzip it and Import file using MakeCode online editor (code is in attachments): https://makecode.microbit.org/
Download code using big button Download and save it on the micro:bit board. Turn on micro:bit and turn on motors, the robot will start operating.
Video how it is moving, I tested robot during the video, so the performance of the robot, not the best one.
The Second Program Is Designed for Line FollowingTo program the robot for that mode, delete previous blocks and insert a new block "call lineFollow" from the functions section.
Download code using big button Download and save it on the micro:bit board. Turn on micro:bit and turn on motors, the robot will start operating.
ConclusionUsing my information you can try by yourself build a micro:bit robotic car and use it for multitasking activities. Good luck! If you faced difficulties, don't hesitate to connect with me, I will try to help you.
Comments