45.00 JD                    Add to cart

 Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

   8.00 JD                      Add to cart 


GPIO Python Module 


The GPIO pins can be used as both digital outputs and digital inputs. The High and Low levels are 3.3 volts and 0 volts. higher voltages may damage your PI.

The figure belwo shows the pinout for Raspberry Pi Rev 2.

    To start using thr GPIOs you need to install a library called Rpi.GPIO. This module gives you a simple to use Python library that will let us control the GPIO pins. This library may be included in your image but doing the following steps will get you the lates version of this library.

 sudo apt-get update
 sudo apt-get install python-dev
 sudo apt-get install python-rpi.gpio                                        



You will probably be prompted to confirm by entering 'Y'.Thats all there is to it. You are ready to proceed.

Usage Exammple

import RPi.GPIO as GPIO

 # to use Raspberry Pi board pin numbers

 # set up the GPIO channels - one input and one output 
 GPIO.setup(11, GPIO.IN) GPIO.setup(12, GPIO.OUT) 

 # input from pin 11 
 input_value = GPIO.input(11) 

 # output to pin 12 
 GPIO.output(12, GPIO.HIGH)

 # the same script as above but using BCM GPIO 00..nn numbers 
 GPIO.setup(17, GPIO.IN) 
 GPIO.setup(18, GPIO.OUT) input_value = GPIO.input(17)
 GPIO.output(18, GPIO.HIGH)