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 realize raspberry pie video car through python socket communication + mjpg

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Editor to share with you how to use python socket communication + mjpg to achieve raspberry pie video car, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!

Required materials: raspberry pie 2B or above, L2985n drive board, several wires, battery and battery box, usb wireless card (no drive), usb camera (no drive).

Required environment: raspberry-gpio-python, as well as installation of mjpg-streamer and the required environment. (I won't say much here, but when bloggers have time to add the configuration of these environments in the future)

All right, here we go.

First of all, we first connect the IN1,IN2,IN3,IN4 of L2985n with four mother-to-mother Dubon wires, and then match the GPIO interface of raspberry pie. (IN1=12,IN2=11,IN3=13,IN4=15)

IN1,IN2 controls OUT1,OUT2 's motor.

IN3,IN4 controls OUT3,OUT4 's motor.

(note that the motor wiring should be crossed between the left and the left, that is, the left front wheel and the left rear wheel. And so on the right. )

Raspberry pie PIN footprints borrow from the raspberry pie lab. Due to the blogger's laziness, the detailed wiring method is not shown above. )

After the connection is finished, enter the raspberry pie by ssh through the method on the network. Enter the command: sudo nano start.py (copy the server code) and then enter Y and enter in Ctrl+x. Enter the command: sudo python start.py (run it!)

The control code of the car server is attached:

# Writer: Joker # # Time: 2017.6.25 # # #-*-coding: utf-8-*-import RPi.GPIO as GPIOfrom socket import * import timedef t_init (): GPIO.setmode (GPIO.BOARD) GPIO.setwarnings (False) GPIO.setup GPIO.OUT) GPIO.setup (12 False GPIO.OUT) GPIO.setup (13mGIO.OUT) GPIO.setup (15pcGIO.OUT) def t_stop (): GPIO.output (11, False) GPIO.output (12, False) GPIO.output (13, False) GPIO.output (13, False) GPIO.output (15 False) time.sleep (1) GPIO.cleanup () def t_up (): t_init () GPIO.output (11, True) GPIO.output (12, False) GPIO.output (13, True) GPIO.output (15, False) time.sleep (1) GPIO.cleanup () def t_down (): t_init () GPIO.output (11, False) GPIO.output True) GPIO.output (13, False) GPIO.output (15, True) time.sleep (1) GPIO.cleanup () def t_right (): t_init () GPIO.output (11, False) GPIO.output (12, True) GPIO.output (13, True) GPIO.output (15 False) time.sleep (1) GPIO.cleanup () def t_left (): t_init () GPIO.output (11, True) GPIO.output (12, False) GPIO.output (13, False) GPIO.output (15 True) time.sleep (1) GPIO.cleanup () def commands (cmd): if cmd = = 'dwells: t_down () elif cmd = =' t_stop: t_stop () elif cmd = = 'Upright: t_up () elif cmd = =' lump: t_left () elif cmd = = 'ritual: t_right () while 1: conn, addr = s.accept () print (' Connected by:' Addr) while 1: command= conn.recv (20). Replace '') if command = = 'conn.close break elif not command:break print a commands: conn.close break elif not command:break print a commands (a) conn.close () conn.close () # # # above are all the contents of the article "how to implement a raspberry pie video car through python socket communication + mjpg" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.

Share To

Internet Technology

Wechat

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

12
Report