![]() ![]() To set the output state of a GPIO pin, call: It will return a value of 0, GPIO.LOW, or False (all are equivalent) if it is low and 1, GPIO.HIGH, or True if it was at a high level. Where channel is the channel number as used in setup. To read the value of an input channel, call: Where channel is the channel number based on the numbering system you specified when you called setmode. To set up a channel as an input or an output, call either: The BOARD number scheme has the advantage that the library is aware of the Raspberry Pi model it is running on and will work correctly even if the Broadcom SOC channel names change in the future. To use physical board pin numbers, call:Įither method will work. For example, pin 24 is BCM channel GPIO8. RPi.GPIO supports referring to GPIO pins using either the physical pin numbers on the GPIO connector or using the BCM channel names from the Broadcom SOC that the pins are connected to. This way you can refer to all functions in the module using the shorter name "GPIO". To use the module from Python programs, first import it using: The RPi.GPIO module is installed by default on recent versions of Raspbian Linux. The project Wiki has documentation including example programs. It was developed by Ben Croston and released under an MIT free software license. Raspberry-gpio-python or RPi.GPIO, is a Python module to control the GPIO interface on the Raspberry Pi. The example code in this blog post is written for Python 3 and should work on any Raspberry Pi model. They are compiled at run time into an intermediate bytecode which is executed by a virtual machine. Being an interpreter there is no need to explicitly compile programs. ![]() The "Pi" in Raspberry Pi standards for "Python Interpreter," reflecting the fact that this is the recommended language on the platform.Ī nice feature of Python is that, being an interpreter, you can type in and try commands interactively without needing to create a program. It is currently one of the most popular and fastest growing programming languages. Python is an interpreted, high-level, general-purpose programming language that has been around since 1991. In this blog post we'll look at how to control Raspberry Pi GPIO pins from the Python programming language using two different modules: Rpi.GPIO and Gpiozero. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |