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 use raspberry pie to make a simple remote control car

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use raspberry pie to make a simple remote control car. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Preparatory work

Raspberry pie, (this article uses Raspberry PI 2 B, that is 2B)

List of available and unavailable SD cards on raspberry pie with TF card above 8G

The bottom of the four-wheel drive car (including motor, note: the chassis of the car in this paper is wearing a high-torque DC motor)

Mother-to-mother, public-to-mother, public-to-public (but not necessary) DuPont line

L298N double HD bridge motor drive board

Wireless network card (preferably AP-enabled)

Rechargeable battery pack (NiMH or 18650 rechargeable battery above 7V)

System installation is nothing to say, the system burns to SD on it, I use Raspbian, this product is based on Debian, configuration command habit is almost the same as ubuntu/debian, connected to the Internet line boot into the system configuration.

Replace the source of China University of Science and Technology and apt-get update again.

Set the password for the root user

There are two ways to configure a wireless network card. Edit / etc/network/interface, and there are many online tutorials:

Automatically connect to the router, there is a wireless router at home, the car is in the place covered by WIFI

Set up WIFI hotspots on raspberry pie, the signal is better, you can open it in the community, by the way, hook up with girls, oh oh, no, it should be naughty children. The only thing to pay attention to is the network card chip.

Chassis assembly

It is not difficult to assemble. The Kraft paper on the acrylic board is almost insane. It took a long time to ⊙ the Kraft ⊙.

The product of the motor was rather lame. It was bare metal without wire, and there happened to be no electric soldering iron in my hand. I was confused at that time. All right, there is an extra DuPont wire in hand, unplug one end of the joint, burn the lighter (the magic skill I learned when I was a child), unplug some of it and tighten the copper wire. Finally, the copper wire passes through the small hole in the motor interface and then tightens. Ah, there is no tape, and finally make do with transparent glue and tie it tightly. Repeat 4 times.

Line connection

I have never played with hardware before. After all, I am only a programmer born as a net worker. I first got L298N and studied it for a long time before I realized that it was still the picture above.

+ 12V interface + 5V~+35V. If you need to pick up power in the board, the power supply range is Vs:+7V~+35V.

Motor OUT1 and OUT2 are motor An output, OUT3 and OUT4 are motor B output

IO interface ENA and ENA are the enabling ends of An and B motors respectively. At the beginning, the upper and lower pins of ENA and ENB are connected by jumper caps, so they can be connected by unplugging. IN1-IN4 is the control input for IO.

After figuring out L298N, the connection is much easier.

OUT1 OUT2 connects the front and rear motors on the left side of the car (in parallel). The DuPont line male from the previous motor is plugged directly into the interface (so shy) to tighten the screws; similarly, OUT3 OUT4 connects the front and rear motors on the right side of the car.

The cheap Ni-MH battery pack's positive and negative electrodes are connected to 12V and GND respectively, and the connector of the battery pack is JST female, which is better to connect.

The 5V and GND are connected to the 5V and GND on the raspberry pie for power.

ENA, ENB, and IN1-IN4 are connected to the raspberry pie Igamot O port.

After you pick it up, it looks like this:

Camera module

The camera is the camera used on desktops several years ago, with a weird 470x640 resolution, instead of 480x640 mjpg color streamer, the picture is flowery, but when the screen is set to normal, the picture is like a slide show. what the hell! The camera is connected to the wndr3800 router with openwrt and has no friends, but I can't move around on the raspberry pie. I accept my fate and give up. I can drive a remote control car without a camera.

Car remote control

Finally to the programming part, in order to simplify, use the RPI.GPIO module of python to operate Icano, but I found that the function is quite few, can not find the speed regulation of API, the document is here, the code is as follows, the parameters of the wheel depend on the port of Icano.

Import RPi.GPIO as gpioclass Wheel (object): def _ _ init__ (self, in_pin1, in_pin2, enable_pin1) Enable_pin2):'': param in_pin1 in_pin2: IN1 IN2 or IN3 IN4: param enable_pin1 enable_pin2: ENA or ENB''self.pin1 = in_pin1 self.pin2 = in_pin2 # setup I OUT gpio.setup O OUT gpio.setup (in_pin1 Gpio.OUT) gpio.setup (in_pin2, gpio.OUT) gpio.setup (enable_pin1, gpio.OUT) gpio.setup (enable_pin2, gpio.OUT) # enable gpio.output (enable_pin1, True) gpio.output (enable_pin2 True) def forward (self): gpio.output (self.pin1, True) gpio.output (self.pin2, False) def backward (self): gpio.output (self.pin1, False) gpio.output (self.pin2, True) def stop (self): gpio.output (self.pin1 False) gpio.output (self.pin2, False) class Car (object): def _ _ init__ (self): gpio.setmode (gpio.BOARD) self.left_wheel = Wheel (13,15,7,11) self.right_wheel = Wheel (16,18,22) 29) def forward (self): self.left_wheel.forward () self.right_wheel.forward () def backward (self): self.left_wheel.backward () self.right_wheel.backward () def left (self): self.left_wheel.stop () Self.right_wheel.forward () def right (self): self.left_wheel.forward () self.right_wheel.stop () def stop (self): self.left_wheel.stop () self.right_wheel.stop () def shutdown (self): Self.stop () gpio.cleanup () Thank you for reading! This is the end of the article on "how to use raspberry pie to make a simple remote control car". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!

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