In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how MicroPython DIY infrared tracking car related knowledge, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
1. Experimental purpose
Research on intelligent car combined with infrared probe tracking forward.
two。 Experimental materials
TPYBoard development board 1 (can run python language development board, car's brain. )
Four-way infrared sensor probe (the eyes of the car).
A data cable.
Portable battery alone (supplies power to the whole system).
Intelligent car chassis (including drive module).
How many DuPont lines.
The purpose of the experiment and the experimental materials are ready, let's first introduce the main components.
2.1PYBoard development board
MicroPython is a Python that can run on a single-chip microcomputer, that is to say, you can develop a single-chip microcomputer program through Python scripting language. Designed by George Daming, a theoretical physicist at the University of Cambridge. Similar to Arduino, but MicroPython is more powerful. The MicroPython development board allows you to easily control various peripherals of the microcontroller, such as LED, read pin voltage, play songs, connect with other devices, and so on, through Python code. TPYBoard is a MicroPython development board made by TurnipSmart. This development board runs smoothly. The key is that the price is very cheap.
2.2 four-way infrared induction probe
The main results are as follows: 1. When the module detects the front obstacle signal, the red indicator light on the circuit board, and the OUT port continuously outputs low-level signals. The module detects distance 2~60cm, detection angle 35 °, detection distance can be adjusted by potentiometer, clockwise potentiometer increases detection distance; counterclockwise potentiometer reduces detection distance.
2. The sensor belongs to infrared reflection detection, so the reflectivity and shape of the target are the key to the detection distance. Among them, black detection distance is the smallest, white is the largest; small area object distance is small, large area distance is large.
3. The output port OUT of the sensor module can be directly connected with the IO port of the single-chip microcomputer, or it can directly drive a 5V relay module or buzzer module; connection mode: VCC-VCC;GND-GND;OUT-IO
4. The comparator adopts LM339 and works stably.
5. 3.3V-5V DC power supply can be used to supply power to the module. When the power is on, the green power indicator lights up.
2.3 Intelligent car chassis
Double motor drive, universal wheel changes direction. This is the most commonly used car chassis in the experiment, using the method of differential speed to turn. With the use of L298N motor drive module, the use method is very simple, not much introduction.
3. Tracking principle
After talking about the problem of raw materials, let's talk about the principle of car tracking.
3.1 installation of infrared probe
The principle of car tracking is actually the absorption, reflection and scattering of light. As we all know, white reflects light of all colors, while black absorbs light of all colors, which provides a strong scientific basis for car tracking. Install infrared probes on the front of the car (I installed four) and arrange them in one word order. When which probe does not receive the reflected or scattered light, it means that the probe is on the black tracking band at this time.
3.2 judgment of the return signal
If the probe straight ahead cannot receive light, then the car is walking on the black tracking belt at this time. It can make the car walk in a straight line. If the probe on the left side does not receive light, then there is a black tracking band on the left side of the car, and the car should make a left turn. Turning right is the same as turning left.
If there is no light in front of the car, on the left, or on the right, or if the probe in both directions cannot receive light, whether it is to turn left, turn right or continue to go straight, it depends on how you judge in the program.
4. Hardware wiring:
In fact, the wiring of the four-way infrared probe is very simple. Although there are eighteen wires, twelve are three and three are divided into four groups, corresponding to good wiring. The remaining six are VCC and GND, and four are directly connected to the IO port of the monolithic knot. The wiring of L298N is simpler, and there is not much introduction here.
The last simple schematic to help understand (in fact, we do experiments are plugged in, not PCB diagrams and schematic diagrams).
Let me show you a physical picture.
5. Operation and debugging
After the completion of the production, the rest is the debugging, debugging should pay attention to the details and the optimization of the stability of the car.
6. Code writing
Let me show you the program I wrote. If you need it, you can take a look at it.
Source code:
Import pybfrom pyb import UARTfrom pyb import PinM0 = Pin ('X1Christ, Pin.IN) M1 = Pin (' X2shipping, Pin.IN) M2 = Pin ('X3shipping, Pin.IN) M3 = Pin (' X4shipping, Pin.IN) N1 = Pin ('Y1Christ, Pin.OUT_PP) N2 = Pin (' Y2shipping, Pin.OUT_PP) N3 = Pin ('Y3shipping, Pin.OUT_PP) N4 = Pin (' Y4') Pin.OUT_PP) print ('while') while True: print (' while') pyb.LED (4). Off () pyb.LED (3). Off () pyb.LED (2). Off () if (M0.value () = = 1): # object returned 0 was detected. Pyb.LED (4). On () pyb.delay (50) N1.low () N2.high () N3.low () N4.high () pyb.delay (30) # pyb.delay (5000) if (M3.value () = = 1): # object returned 0 was detected Pyb.LED (3). On () pyb.delay (50) N1.high () N2.low () N3.high () N4.low () pyb.delay (30) if (M2.value () & M1.value () = = 1): pyb.LED (2). On () N1.low () N2.high () N3.high () N4.low () pyb.delay (70) are all the contents of the article "how to DIY infrared tracking car by MicroPython". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.