{"id":3805,"date":"2024-11-21T11:45:39","date_gmt":"2024-11-21T11:45:39","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=3805"},"modified":"2024-11-21T12:01:12","modified_gmt":"2024-11-21T12:01:12","slug":"io-pins-and-input-outputs","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-python\/gpio-zero\/io-pins-and-input-outputs","title":{"rendered":"IO pins and input &amp; outputs"},"content":{"rendered":"\n<p>GPIO Zero makes you access pins as if they are devices, but you can use them like normal inputs and outputs too.<\/p>\n\n\n\n<p><a href=\"https:\/\/gpiozero.readthedocs.io\/en\/stable\/api_input.html#inputdevice\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/gpiozero.readthedocs.io\/en\/stable\/api_input.html#inputdevice<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/gpiozero.readthedocs.io\/en\/stable\/api_output.html#gpiozero.OutputDevice\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/gpiozero.readthedocs.io\/en\/stable\/api_output.html#gpiozero.OutputDevice<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from gpiozero import InputDevice, OutputDevice\n\n\/\/Setup an input\nio_my_input = InputDevice(3, pull_up=False)    \/\/Use BCM pin numbering, so the GPIO# number (not the connector pin number)\n#io_my_input = InputDevice(3, pull_up=True)\n\n\/\/Using an input\nif io_my_input.value == 0:\n\n\n\/\/Setup an output\nio_my_output = OutputDevice(17)    \/\/Use BCM pin numbering, so the GPIO# number (not the connector pin number)\n\n\/\/Using an otuput\nio_my_output.off()\nio_my_output.on()\nio_my_output.toggle()\nio_my_output.value = 1    #Set to 0 or 1, you can also read this<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[195],"tags":[],"class_list":["post-3805","post","type-post","status-publish","format-standard","hentry","category-gpio-zero"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=3805"}],"version-history":[{"count":6,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3805\/revisions"}],"predecessor-version":[{"id":3812,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3805\/revisions\/3812"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=3805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=3805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=3805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}