Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to DIY Bluetooth Intelligent car by Micropython

2025-01-21 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 "Micropython how to DIY Bluetooth smart car". 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

1. Learn the method of extending the simple Iripple O interface in the PC system.

two。 Further learn the design method of compiling data output program.

3. Learn the wiring method and working principle of Bluetooth module.

4. Learn the wiring method of L298N motor driver board module.

5. Learn the working principle of Bluetooth control car.

two。 Required components

TPYBoard board

One Bluetooth serial port module

One module of L298N motor driver board

An intelligent car chassis.

A data line

Some DuPont lines

3. Principle of Bluetooth Serial Port Module

(1) the lead-out interface includes EN,5V,GND,TX,RX,STATE, and our car only uses four RX,TX,GND,5V pins.

(2) the default baud bit of the module is 9600, the default pairing password is 1234, and the default name bit is 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 figure wiring, 5V connected to TPYBoard VIN,GND as the ground wire, TX connected to TPYBoard RX (this is using the TPYBoard serial port 2 Magi X3PowerX4), that is, X4 Magi RX connected to TPYBoard TX X3.

4. Learn the wiring method of L298N motor driver board module

This module is a 2-way H-bridge drive, so it can drive two motors at the same time. After the ENAENB is enabled as shown in the figure, the speed and direction of the motor 1 can be driven by the PWM signal input from the IN1IN2, and the speed and direction of the motor 2 can be driven by the PWM signal from the IN3IN4. We connect the OUT1 and OUT2 of the motor 1 interface with the positive and negative electrodes of one motor of the car, and connect the OUT3 and OUT2 of the motor 2 interface with the positive and negative electrodes of the other motor of the car. Then connect the terminals on both sides, that is, the power supply positive terminal (the middle terminal is grounded) to the VIN of TPYboard, and the middle terminal is grounded. The GND,In1-In4 connecting TPYBoard is connected to TPYBoard's Y1Magi Y2mY3Magi Y4, which controls the rotation of the motor through the high and low levels of Y1Mague Y2 and Y3Magi Y4, so that the car can move forward, backward, left and right.

After wiring the ok, write main.py, power up the TOYBoard and ok it. Here is the source code.

5. source code

Import pybfrom pyb import UARTfrom pyb import PinM2 = Pin ('X3cycles, Pin.IN) M3 = Pin (' X4legs, Pin.IN) N1 = Pin ('Y1mm, Pin.OUT_PP) N2 = Pin (' Y2cycles, Pin.OUT_PP) N3 = Pin ('Y3cycles, Pin.OUT_PP) N4 = Pin (' Y4miles, Pin.OUT_PP) U2 = UART (2) 9600) while True: pyb.LED (2). On () pyb.LED (3). On () pyb.LED (4). On () _ dataRead=u2.readall () if _ dataReadsheets none: # stop (read the instructions sent by the APP from the phone Different software instructions may be different and can be set by yourself, which is the default here. Same below) if (_ dataRead.find (b'\ xa5Z\ X04\ xb1\ xb5\ xaa') >-1): print ('stop') N1.low () N2.low () N3.low () N4.low () # left elif (_ dataRead.find (b'\ xa5Z\ X04\ xb4\ xb8\ xaa') ) >-1): print ('left') N1.low () N2.high () N3.high () N4.low () # right elif (_ dataRead.find (b'\ xa5Z\ X04\ xb6\ xba\ xaa') >-1): print ('right') N1.high () N2.low () N3.low () N4.high () # back elif (_ dataRead.find (b'\ xa5Z\ X04\ xb5\ xb9\ xaa') >-1): print ('back') N2.high () N1.low () N4.high () N3.low () # forward elif (_ dataRead.find (b'\ xa5Z\ X04\ xb2\ xb6\ xaa') >-1): print ('go') N1.high () N2.low () N3.high () N4.low () "how Micropython DIY Bluetooth Smart car" 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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report