In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to make an infrared anti-falling car by python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
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
(brain)
Four-way infrared sensor probe (eyes of the car)
A data cable.
Portable battery alone (supplies power to the whole system)
Intelligent car chassis (including drive module)
Some DuPont lines
The purpose of the experiment and the experimental materials are ready, let's first introduce the main components.
2.1 TPYBoard 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 Micro Python 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. For more information, please refer to its official website http://www.micropython.net.cn.
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. There is a mounting hole in the front of the car, and the infrared sensor is fixed on the mounting hole with screws. Keep both the transmitter and receiver straight down.
3.2 judgment of the return signal
As mentioned above, when the infrared probe detects the presence of an object, it will continue to output a low level at the out end. Then adjust the distance adjustment resistance, adjust to a suitable detection distance. When the car detects an object on the road, it shows that there is a road ahead, not in the air. So keep the car straight. If there is no return detected in the front, and no return indicates that no object has been detected, the mother indicates that there is no road ahead and is suspended, then the car will go back first and turn right (you can also turn left, or you can turn right and turn left at a time). This is more casual. ).
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.
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 Pin M0 = Pin ('X1Christ, Pin.IN) M1 = Pin (' X2shipping, Pin.IN) M2 = Pin ('X3shipping, Pin.IN) M3 = Pin (' X4bath, 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') if (M2.value () | M1.value () | M3.value () | M0.value () = = 0): N1.low () N2.high () N4.high () N3.low () pyb.LED (2). On () pyb.LED (3). Off () elif (M2) .value () | M1.value () | M3.value () | M0.value () = = 1): N1.high () N2.low () N4.low () N3.high () pyb.delay () N1.low () N2.high () N3.high () pyb.delay () pyb. LED (3). On () pyb.LED (2). Off () "how to make an infrared anti-falling car by python" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.