GPIO Zero makes you access pins as if they are devices, but you can use them like normal inputs and outputs too.
https://gpiozero.readthedocs.io/en/stable/api_input.html#inputdevice
https://gpiozero.readthedocs.io/en/stable/api_output.html#gpiozero.OutputDevice
from gpiozero import InputDevice, OutputDevice
//Setup an input
io_my_input = InputDevice(3, pull_up=False) //Use BCM pin numbering, so the GPIO# number (not the connector pin number)
#io_my_input = InputDevice(3, pull_up=True)
//Using an input
if io_my_input.value == 0:
//Setup an output
io_my_output = OutputDevice(17) //Use BCM pin numbering, so the GPIO# number (not the connector pin number)
//Using an otuput
io_my_output.off()
io_my_output.on()
io_my_output.toggle()
io_my_output.value = 1 #Set to 0 or 1, you can also read this
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.