Android uses socket to control raspberry pie gpio mouth python3.4 Implementation __python

Source: Internet
Author: User

Reprint please indicate the source, thank you.
Raspberry Pie provides the Python language implementation of the Gpio control pack, detailed description of the visible http://maxembedded.com/2014/07/using-raspberry-pi-gpio-using-python/#PinConfig. First in the system to open the terminal to perform Python check whether the Python and Python version is installed 2 or 3, this article uses the python3.4 implementation. After checking the installation state of Python, this article uses the online installation method, download decompression installation Gpio module mode is not detailed, see the above Web site. Perform the sudo apt-get install python-rpi.gpio python3-rpi.gpio to download the Rpi.gpio module used by the raspberry pie.
The raspberry pie uses the python3.4 IDE to perform sudo python3 server.py
Design objective: Using PIN11 and Pin12 respectively control two lights, pin11 the negative of the blue led, Pin12 connect the cathode of the red Ledd, Pin1 connect the blue and red cathode, connect the way as shown:

First start in the Raspberry pie run the server program, the implementation of sudo python server.py, you need to modify the code in the IP address for the raspberry sent IP address, the port number arbitrary, if prompted socket to create failure, please replace the port number try again.
The Android side is written with the following interface:


The first input box input raspberry IP address and port number, separated by semicolons, click the Connect button will automatically connect to, click on the bottom 4 buttons will be lit red LED, green LED, flash red LED, Green LED.
Effect Chart:

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.