🌐
SparkFun Learn
learn.sparkfun.com › tutorials › raspberry-gpio › all
Raspberry gPIo - SparkFun Learn
It does a little input and output, and even handles some PWM. This assumes you've set up the circuit as arranged on the Hardware Setup page. language:Python # External module imports import RPi.GPIO as GPIO import time # Pin Definitons: pwmPin = 18 # Broadcom pin 18 (P1 pin 12) ledPin = 23 ...
🌐
RasPi.TV
raspi.tv › 2013 › rpi-gpio-basics-6-using-inputs-and-outputs-together-with-rpi-gpio-pull-ups-and-pull-downs
RPi.GPIO basics 6 – Using inputs and outputs together with RPi.GPIO – pull-ups and pull-downs
February 19, 2017 - How do you do that? RPi.GPIO to the rescue. You enable these internal pull-ups/pull-downs at the time of setting up the port for input or output, by adding an extra, optional, argument to the GPIO.setup() function call.
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › community › general discussion
How to configure some GPIO pins as output - Raspberry Pi Forums
You can't. All the GPIO are set to INPUT mode when power is applied to the Pi. ... Thu Apr 12, 2018 11:44 am You can't. All the GPIO are set to INPUT mode when power is applied to the Pi. But can I add the instruction to /etc/rc.local?
🌐
SparkFun Learn
learn.sparkfun.com › tutorials › raspberry-gpio › python-rpigpio-api
Python (RPi.GPIO) API - Raspberry gPIo - SparkFun Learn
To specify in your code which number-system is being used, use the GPIO.setmode() function. For example... ... Both the import and setmode lines of code are required, if you want to use Python. If you've used Arduino, you're probably familiar with the fact that you have to declare a "pin mode" before you can use it as either an input or output.
🌐
PyPI
pypi.org › project › RPi.GPIO
RPi.GPIO · PyPI
Note that the current release does ... on the RPi yet. This is planned for the near future - watch this space! One-wire functionality is also planned. Although hardware PWM is not available yet, software PWM is available to use on all channels. For examples and documentation, visit http://sourceforge.net/p/raspberry-gpio-python/w...
      » pip install RPi.GPIO
    
Published   Feb 06, 2022
Version   0.7.1
🌐
Pinout.xyz
pinout.xyz
Raspberry Pi GPIO Pinout
GPIO - General Purpose Input/Output, aka "BCM" or "Broadcom". These are the big numbers, e.g. "GPIO 22". You'll use these with RPi.GPIO and GPIO Zero.
🌐
SourceForge
sourceforge.net › home › browse › raspberry-gpio-python › wiki
raspberry-gpio-python / Wiki / Inputs
The event_detected() function is designed to be used in a loop with other things, but unlike polling it is not going to miss the change in state of an input while the CPU is busy working on other things. This could be useful when using something like Pygame or PyQt where there is a main loop listening and responding to GUI events in a timely basis. GPIO.add_event_detect(channel, GPIO.RISING) # add rising edge detection on a channel do_something() if GPIO.event_detected(channel): print('Button pressed') Note that you can detect events for GPIO.RISING, GPIO.FALLING or GPIO.BOTH. RPi.GPIO runs a second thread for callback functions.
🌐
Raspberry Pi
raspberrypi.org › documentation › usage › gpio
Raspberry Pi OS - Raspberry Pi Documentation
Using the GPIO Zero library makes it easy to control GPIO devices with Python.
Find elsewhere
🌐
RasPi.TV
raspi.tv › 2013 › rpi-gpio-basics-5-setting-up-and-using-outputs-with-rpi-gpio
RPi.GPIO basics 5 – Setting up and using outputs with RPi.GPIO
June 22, 2015 - GPIO.input(24) Let’s modify the LED script to read the status of GPIO24 (lines 10-11 & 14-15) and give us a message about the LED’s status. (This is a very simple and controlled example. You wouldn’t normally use it in this situation – I’m just showing you how.) import RPi.GPIO as GPIO # import RPi.GPIO module from time import sleep # lets us have a delay GPIO.setmode(GPIO.BCM) # choose BCM or BOARD GPIO.setup(24, GPIO.OUT) # set GPIO24 as an output try: while True: GPIO.output(24, 1) # set GPIO24 to 1/GPIO.HIGH/True sleep(0.5) # wait half a second if GPIO.input(24): print "LED just about to switch off" GPIO.output(24, 0) # set GPIO24 to 0/GPIO.LOW/False sleep(0.5) # wait half a second if not GPIO.input(24): print "LED just about to switch on" except KeyboardInterrupt: # trap a CTRL+C keyboard interrupt GPIO.cleanup() # resets all GPIO ports used by this program
🌐
ICS
ics.com › blog › control-raspberry-pi-gpio-pins-python
Control Raspberry Pi GPIO Pins from Python | ICS
July 31, 2019 - GPIO.cleanup() Here is a very simple standalone example that toggles an output pin on and off for 200 milliseconds, ten times. It also reports the level on input pin 31. If you put the commands in a file and make it executable, you can directly run it as a program. #!/usr/bin/python3 · import RPi.GPIO as GPIO import time ·
🌐
SourceForge
sourceforge.net › home › browse › raspberry-gpio-python › wiki
raspberry-gpio-python / Wiki / BasicUsage
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.
🌐
Random Nerd Tutorials
randomnerdtutorials.com › home › project › raspberry pi › raspberry pi: read digital inputs with python (buttons and other peripherals)
Raspberry Pi: Read Digital Inputs with Python (Buttons and Other Peripherals) | Random Nerd Tutorials
July 19, 2023 - In this guide, you'll learn how to set the Raspberry Pi GPIOs as digital inputs and how to read their state using a Python program. As an example, we'll read the state of a pushbutton (pressed or not pressed), but the example can be applied to any other peripherals that output digital signals.
🌐
Raspberry Pi
raspberrypihq.com › home › using a push button with raspberry pi gpio
Using a push button with Raspberry Pi GPIO | Raspberry Pi HQ
October 9, 2025 - import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library def button_callback(channel): print("Button was pushed!") Next the program will initialize the input pin as follows:
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Python Script to read one pin - Raspberry Pi Forums
November 10, 2021 - As has been pointed out, you are only reading the input once, before you start looping, read through this code and see if it makes more sense: ... #!/usr/bin/env python from time import sleep # Allows us to call the sleep function to slow down our loop import RPi.GPIO as GPIO # Allows us to call our GPIO pins and names it just GPIO GPIO.setmode(GPIO.BCM) # Set's GPIO pins to BCM GPIO numbering INPUT_PIN = 4 # Sets our input pin, in this example I'm connecting our button to pin 4.
🌐
Oreilly
razzpisampler.oreilly.com › ch07.html
Connecting a Push Switch - razzpisampler - O'Reilly
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: input_state = GPIO.input(18) if input_state == False: print('Button Pressed') time.sleep(0.2)
🌐
University of Cambridge
cl.cam.ac.uk › projects › raspberrypi › tutorials › turing-machine › two.html
Department of Computer Science and Technology – Raspberry Pi: Section 2: GPIO
GPIO, as may have been explained in other tutorials, stands for General Purpose Input/Output and a GPIO pin can be set high (taking the value 1) by connecting it to a voltage supply, or set low (taking the value 0) by connecting it to ground.