Giter Club home page Giter Club logo

raspberry-py-gpio's Introduction

GPIO

  • import to library ๐Ÿ“š
import RPi.GPIO as GPIO
import time
  • set to mode ๐Ÿ”ง
GPIO.setmode(GPIO.BCM)
or
GPIO.setmode(GPIO.BOARD)

The board revision of the RPi

Warnings

It is possible that you have more than one script/circuit on the GPIO of your Raspberry Pi. As a result of this, if RPi.GPIO detects that a pin has been configured to something other than the default (input), you get a warning when you try to configure a script. To disable these warnings:

GPIO.setwarnings(False)

Setup up a channel

You need to set up every channel you are using as an input or an output. To configure a channel as an input:

GPIO.setup(channel, GPIO.IN)

To set up a channel as an output:

GPIO.setup(channel, GPIO.OUT)

Input

To read the value of a GPIO pin:

GPIO.input(channel)

Output

To set the output state of a GPIO pin:

GPIO.output(channel, state)

Cleanup

At the end any program, it is good practice to clean up any resources you might have used. This is no different with RPi.GPIO. By returning all channels you have used back to inputs with no pull up/down, you can avoid accidental damage to your RPi by shorting out the pins. Note that this will only clean up GPIO channels that your script has used. Note that GPIO.cleanup() also clears the pin numbering system in use.

To clean up at the end of your script:

GPIO.cleanup()

โœ๏ธ Source : SourceForge

raspberry-py-gpio's People

Contributors

burkaydurdu avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.