In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces python how to make Bluetooth + infrared tracking car related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this python how to make Bluetooth + infrared tracking car article will have a harvest, let's take a look.
1. Experimental purpose
Learn the method of extending the simple Iripple O interface in the PC system.
Further learn the design method of compiling data output program.
Learn the wiring method and working principle of Bluetooth module.
Learn the wiring method of L298N motor driver board module.
Learn the working principle of Bluetooth control car.
two。 Required components
1 TPYBoardv102 board
1 Bluetooth serial port transparent transmission module (HC-06)
One module of L298N motor driver board
1 chassis of intelligent car
1 data line
Some DuPont lines
Intelligent Bluetooth car APP (Android version) Click to download
3. Principle of Bluetooth Serial Port Module
(1) the lead-out interface includes EN,5V,GND,TX,RX,STATE. Our car only uses four RX,TX,GND,5V pins.
(2) the module defaults to the baud bit 9600, the default pairing password 1234, and the default name bit HC-06.
(3) led indicates Bluetooth connection status, flashing means there is no Bluetooth connection, always bright means Bluetooth is connected and open port, when we use Android mobile phone software to send instructions, send instructions to TPYBoard through serial port, TPYBoard receives instructions to drive the car forward, backward, left, right or stop through the L298BN module.
The following table wiring:
Bluetooth module (HC-06) TPYBoardv10x5VVIN (+ 5V) GNDGNDRXY9 (UART (3)-TX) TXY10 (UART (3)-RX)
4. Four-way infrared tracking module
The main results are as follows: (1) when the module detects the front obstacle signal, the red light on the circuit board is lit, and the OUT port continuously outputs low-level signals, the detection distance of the module is 2~60cm, the detection angle is 35 °, the detection distance can be adjusted by potentiometer, the detection distance is increased by clockwise potentiometer, and the detection distance is reduced by counterclockwise potentiometer.
(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 power the module. When the power is on, the green power indicator lights up.
5. Installation of four-way infrared induction probe
The principle of tracing 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.
6. Judge the feedback 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.
7. Installation and wiring of probe
Four-way infrared probe wiring is very simple, although there are eighteen wires, but twelve are three into four groups, one-to-one corresponding wiring, the other six are VCC and GND. The other four are connected to the IO port of the TPYBoardv10x development board and are used to receive signals from the four-channel infrared tracking module.
After wiring the OK, write main.py, power up the TPYBoard and ok it. Here is the source code.
8. source code
# main.py-- put your code hereafter imports import pybfrom pyb import UARTfrom pyb import PinN1 = Pin ('X1, Pin.OUT_PP) N2 = Pin ('X2, Pin.OUT_PP) N3 = Pin ('X3, Pin.OUT_PP) N4 = Pin ('X4, Pin.OUT_PP) M1 = Pin ('Y1, Pin.IN) M2 = Pin ('Y2, Pin.IN) M3 = Pin ('Y3, Pin.IN) M4 = Pin ('Y4' Pin.IN) blue=UART (3p9600) mode='1'#1: indicates Bluetooth mode 2: trace mode def Stop (): N1.low () N2.low () N3.low () N4.low () def Back (): N1.high () N2.low () N3.high () N4.low () def Go (): N1.low () N2.high () N3.low () N4.high () def Left (): N1.high () N2.low () N3.low () N4.high () def Right (): N1.low () N2.high () N3.high () N4.low () while True: if blue.any () > 0: data=blue.read () .decode () print (data) if data.find ('0') > -1: # stop Stop () mode= "1" print ('stop') if data.find (' 1') >-1: Go () print ('go') if data.find (' 2') >-1: Back () pyb.delay Stop () if data.find ('3') >-1: Left () pyb.delay (250) Stop () if data.find ('4') >-1: Right () pyb.delay (250) Stop () if data.find ('5') >-1: Mode= "1" Stop () if data.find ('6') >-1: mode= "2" else: if mode== "2": print ('trace mode') if (M1.value () and M2.value () and M3.value ()): Stop () mode= " 1 "if (M2.value () or M3.value ()): pyb.LED (2). On () pyb.LED (3). Off () pyb.LED (4). Off () Go () if M1.value (): pyb.LED (3). On () Pyb.LED (2). Off () pyb.LED (4). Off () Right () pyb.delay (10) if M4.value (): pyb.LED (4). On () pyb.LED (2). Off () pyb.LED (3) off () Left () pyb.delay (10)
9. The use of Intelligent Bluetooth car APP
After downloading and installing, open the [Bluetooth Smart car] APP and enter the operation interface. As follows:
Click the peach heart icon in the lower left corner to enter the custom coding interface. Through this interface, we can customize the contents of the instructions sent out by each button in the interface.
Next, go back to the initial user interface and click the settings icon in the lower right corner to connect the Bluetooth module. First click [search Bluetooth device], the interface will automatically load the searched Bluetooth device, when the HC- appears at 06:00, click to connect.
If it is the first time to connect, it needs to be paired. The default password for pairing is 1234.
After the connection is successful, we can use four arrow keys to operate the smart Bluetooth car.
As you can see, the icon in the upper right corner can switch between Bluetooth mode and tracking mode. When pressed, the two modes switch back and forth. When in tracking mode, the interface is as follows.
This is the end of the article on "how to make Bluetooth + Infrared tracking car in python". Thank you for reading! I believe that everyone has a certain understanding of "how to make Bluetooth + infrared tracking car in python". If you want to learn more, you are welcome to follow 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.