Gpio Control Knowledge Supplement

Source: Internet
Author: User

Rpi.gpio Module Function Description:

RPi.GPIO.setmode (Naming_system)

Sets the way the Gpio pin is named. Naming_system available values are RPi.GPIO.BCM and RPi.GPIO.BOARD, which represent the naming system on the boardcom naming system and the Raspberry Pi Board, respectively. And since the use of BCM (said) different versions of the BVM PIN definition is not the same, so the same set of programs used on multiple Raspberry Pi system is recommended to use board.

RPi.GPIO.setup (channel, state)

The pin labeled channel is set to state mode. The channel value is 1~26,state value of RPi.GPIO.IN or RPi.GPIO.OUT, respectively, representing input and output. For example, RPi.GPIO.setup (1, RPi.GPIO.IN) indicates that the 1th pin is set to input mode, and RPi.GPIO.setup (3, RPi.GPIO.OUT) indicates that the 3rd pin is set to output mode. Exactly which number is the root depends on what is set in SetMode ().

RPi.GPIO.output (channel, state)

Sets the pin labeled channel to the level specified by state. Channel values of 1~26,state are RPi.GPIO.HIGH and RPi.GPIO.LOW, or 1 and 0, or true and false, indicating high and low levels. For example, RPi.GPIO.output (1, 1) indicates that the 1th pin is set to high, and RPi.GPIO.output (3, flase) indicates that the 3rd PIN is set to low. Exactly which number is the root depends on what is set in SetMode ().

RPi.GPIO.input (channel)

Gets the level bricks that will be labeled as channel pins. The channel value is 1~26. For example, RPi.GPIO.input (1) indicates that the state of the 1th pin is obtained.

RPi.GPIO.cleanup ()

Clears the state of the RPi.GPIO.setup () setting before it is removed. Must be called before exiting the program, otherwise the next call will be an error.

led.py Module Description

The channel holds the label of the needle used in the connection, in order.

Init () is the code that initializes the Gpio interface, which is called before it is used to control the LCD. The main task is to set the interface naming pattern and set the pin in the channel to output mode

On ()/Off () sets the first pin in channel to high/low

CTRL () Sets the level of all 8 pins according to the parameters. Low 0-bit, low 1-bit, low-2-bit for parameters ... The channel subscript is 0, 1, 2, respectively. The level condition of the PIN, 1 is high, 0 is low

Test () is a testing function. The state of 8 lights is represented by a 8-bit binary, every 0.1 seconds to the next state: 0000 0000, 0000 0001, 0000 0010, 0000 0011,0000 0100 ... Actually, it's from 0 to 255.

Clean () is an encapsulation of RPi.GPIO.cleanup ()

Gpio Control Knowledge Supplement

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.