![]() To set a pin as an input pin use: import RPi.GPIO as GPIO toutput(4,1) #set value of GPIO4 to True or 1 Using the BCM format we use: import RPi.GPIO as GPIO To use a pin you need to first set the numbering scheme and then designate the Pin as either an input or an output pin. Or import gpiozero Using The RPI.GPIO Module They are:īoth modules are normally installed but the install procedures can be found on the reference pages above. There are two modules that can be used for controlling i.e reading and writing to the pins. Simple guide to the Raspberry pi GPIO pins Controlling The Pins Using Python Note: diagram copied from this page which contains complete pin layout GPIO4 corresponds to Board Pin number 7 as shown in the diagram below: Board- uses numbers 1-40 and follows the pin Layout.This aspect I found very confusing at first as there are two systems that are used, and you need to choose which one to use in your scripts. In this tutorial I will cover the basics of using the GPIO pins and show you how to use MQTT to set the pin state and report the pin state using Python. The most common one being the sense hat.Īlthough you will need external hardware like leds etc for various projects there is a lot you can learn without using any. There are a number of add-on boards called hats which plug into these pins and provide various sensors. The Raspberry Pi has 40 General purpose Input/output Pins (GPIO) that can be used for controlling external hardware. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |