zt07elecfreaks 发表于 2018-1-10 18:47:10

Create a Line Follow Car with Micro:bit制作寻线小车

The so-called line follow car means a car follows a black line on the white(or light color)ground. Because the black line and white ground have different reflections to the light, the car can drive according the the strength of the light reflection received. Today, we are going to make a line follow car with micro:bit.
https://www.elecfreaks.com/wp-content/uploads/2018/01/1.gif


Materials Needed:

1 x BBC micro:bit1 x ELECFREAKS Motor:bit1 x Smart Car Chassis2 x Octopus Hunt Sensor2 x 3x12+6 Copper Rod3 x 3x10 Copper Rod2 x 18650 BatteryBlack Adhesive TapesSeveral CablesIn this project, we will mainly use micro:bit and motor:bit.
More details about micro:bit, you can read:Start Your Micro:bit Programming Trip
More details about motor:bit, you can read:Elecfreaks Motor:bit User Guide


Hardware Assembling



Step 1

Weld motor cables. If there are no lead cables on your motors, you have to weld cables for them.
https://www.elecfreaks.com/wp-content/uploads/2018/01/1.jpg


Step 2

Within the package of car chassis, there is a drawing for instruction. You can refer to its instructions and assemble the chassis.
Once finished, you will see the chassis below:
https://www.elecfreaks.com/wp-content/uploads/2018/01/2.jpg


Step 3

Fix motor:bit to the chassis of the car.
https://www.elecfreaks.com/wp-content/uploads/2018/01/3.jpg


Step 4

Plug the two groups of motor cables into connector M1 and M2.
https://www.elecfreaks.com/wp-content/uploads/2018/01/4.jpg


Step 5

Install line follow modules and pay attention to their space. In this project, the space of two line follow modules is about or a little bit smaller than the width of the black adhesive tape.
Plug the two line follow modules into P4 and P5 separately.
https://www.elecfreaks.com/wp-content/uploads/2018/01/5-3.jpg


Step 6

Connect with 6~12v DC power supply. Here, we have connected 2 segments of 18650 batteries in parallel, and then plugged a micro:bit.
https://www.elecfreaks.com/wp-content/uploads/2018/01/6-1.jpg
You can see the whole electric circuit in the below:
https://www.elecfreaks.com/wp-content/uploads/2018/01/7.jpg


Step 7

Draw a trace on the ground with a black adhesive tape.
You have to pay attention to the width of the tape. It is a little bit bigger than the width of two line follow modules.


Step 8

Please download the program below into micro:bit, watch out the rotating directions of the two motors. According to this program, the motors should both move forward. If one motor in the opposite direction, you have to change the cable connection of the motor in error and reconnect motor:bit.
https://www.elecfreaks.com/wp-content/uploads/2018/01/8.png


Step 9

Adjust line follow module to enable recognition of black lines and white base board. If the recognition is not available, you can adjust the sensitivity of the potentiometer on the module.


Programming



Step 1

Since hardware connection is completed, we can start to edit our program now. In this case, lots of pins and micro:bit built-in LED dot matrix can be used repeatedly, so firstly we should turn off the LED screen.
https://www.elecfreaks.com/wp-content/uploads/2018/01/9.png


Step 2

Write program for forwarding, stopping, turning left and right. Control the rotate speed of the motor through analog wite. Bigger value it has, the motor rotates faster.
https://www.elecfreaks.com/wp-content/uploads/2018/01/10.png


Step 3

According to the logic below, write your main program of line follow project.
https://www.elecfreaks.com/wp-content/uploads/2018/01/11.jpg
https://www.elecfreaks.com/wp-content/uploads/2018/01/12.png


Download Program:

You can click Download directly to save the code into micro:bit.



View our little car on YouTube:










Relative Readings

Make A Cool Micro:bit Hovercraft Together


https://www.elecfreaks.com/12181.html
页: [1]
查看完整版本: Create a Line Follow Car with Micro:bit制作寻线小车