Use raspberry to make a simple remote control car

Source: Internet
Author: User

Briefly

This article mainly describes the use of Raspberry Pi and l298n to make a simple remote control car, remote control using a simple web to achieve.

Preparatory work
    1. Raspberry Pi, (this article uses the Raspberry PI 2 type B, i.e. 2B)
    2. 8G above TF card Raspberry Pi available and unavailable SD card list
    3. Four-drive trolley bottom (including motor, Note: The car chassis in this article is wearing a high-torque DC motor)
    4. Mother to mother, male to female, male to male (not available) DuPont Line
    5. L298N dual HD Bridge Motor Drive Board
    6. Wireless Card (preferably AP-supported)
    7. Rechargeable battery pack (up to 7V, NiMH or 18650 rechargeable batteries)

System installation Nothing to say, the system burned to SD can be, I use the Raspbian, this shipment is based on Debian, configuration command habits almost like Ubuntu/debian, connected to the network cable boot into the system configuration.

    • Change the source of Zhong Ke, and then apt-get update once;
    • Set the password for the root user;
    • Configure the wireless card has two programs, edit/etc/network/interface, online tutorials pretty much:
      1. Automatically connected to the router, home to a wireless router, the car in the WiFi coverage of the place;
      2. Raspberry Pi set up WiFi hotspot, signal better, can open in the community, by the way to seduce sister, oh oh oh, no, it should be naughty children. The only thing to note is the NIC chip.
Chassis Assembly
    • Assembling no difficulty, acrylic board on the Kraft paper is simply crazy, horse eggs, waste a good while kung fu just tore clean (⊙﹏⊙) b;
    • Motor that the goods are compared to the pit, no wire is bare metal, hands also happen to have no iron, at that time I was ignorant force. All right, there's an extra male-to-male DuPont line, pull out one of the joints, a lighter to burn (as a child learned divine skills), unplug a part of the copper wire tightening. Finally, the copper wire passes through the small hole in the motor interface and is tightened again. Ah ya, no tape, and finally use Scotch tape make up, tied tight. Repeat 4 times.
Line connection

Never played hardware before, after all, I'm just a web worker from the program ape, the first time to get l298n study for a long while to understand, or.

    1. +12V interface
      +5V~+35V, if need to take power in the board, the supply range vs:+7v~+35v
    2. Motor
      OUT1, OUT2 for motor a output, OUT3, OUT4 for motor b output
    3. Io interface
      Ena and Ena respectively for a, B motor to enable the end, a start Ena and ENB each of the top and bottom two pins are connected with jumper caps, unplug can be wired. The IN1-IN4 is an IO control input.

After figuring out the l298n, the connection is much more convenient,

    • OUT1 OUT2 connecting the car to the left and back two motors (parallel), before the motor connected to the DuPont line head directly into the interface plug (good shame), tighten the screws; Similarly, OUT3 OUT4 connect the car to the right and back two motors;
    • Low-cost Ni-MH battery power supply positive and negative poles are connected to 12V, GND, the battery pack is the JST female connector, relatively good connection;
    • 5V and GND are connected to the Raspberry Pi on 5V and GND for power supply.
    • ENA, ENB, In1-in4 are connected to the Raspberry Pi I/O port.

After that, it looks like this:

Camera Module

Camera is a few years ago the desktop camera, the resolution is a wonderful 470x640, not 480x640,mjpg-streamer, the screen is spent, until the screen is normal, the screen is like a slide. I'll take a walk! Camera connected to the WNDR3800 router installed openwrt fluent no friends, in the Raspberry Pi up to adjust but how can not, resigned, give up, no camera can also when remote control car open.

Car Remote Control

Finally to the programming section, in order to be simple, using Python's Rpi.gpio module to operate I/O, but I found that the function is very few, did not find the speed of the API, the document here, the code as follows, the parameters of the wheel depends on the I/O port.

Import Rpi.gpio as Gpioclass Wheel (object): Def __init__ (self, in_pin1, in_pin2, Enable_pin1, enable_pin2): " :p Aram In_pin1 in_pin2:in1 IN2 or IN3 IN4:p Aram enable_pin1 Enable_pin2:ena or ENB ' self . Pin1 = In_pin1 self.pin2 = in_pin2 # setup I/O Gpio.setup (in_pin1, Gpio. Out) Gpio.setup (in_pin2, Gpio. Out) Gpio.setup (Enable_pin1, Gpio. Out) Gpio.setup (enable_pin2, Gpio.        # 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 (sel F.pin2, False) class Car (object): Def __init__ (self): Gpio.setmode (Gpio). BOARD) Self.left_wheel = Wheel (16, 7, one) Self.right_wheel = Wheel (18, (+) 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 St OP (self): Self.left_wheel.stop () self.right_wheel.stop () def shutdown (self): Self.stop () GP Io.cleanup ()

Finally with the Flask module to achieve the Web (Android really haven't touched, laugh), this needs to be installed in the Raspberry Pi flask module, when the installation of the Raspberry Pi Python environment is not complete. This code is not posted, directly on the warehouse address.

Car remote Control part code: HTTPS://GITHUB.COM/FORDOO/RPI-CAR

Car Demo Gif:http://ww2.sinaimg.cn/bmiddle/a3b0dabfgw1eqed43g2ivg20b20coqv5.gif

Use raspberry to make a simple remote control car

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.