{"id":1794,"date":"2014-01-29T10:01:51","date_gmt":"2014-01-29T10:01:51","guid":{"rendered":"http:\/\/warc.org.uk\/?page_id=1794"},"modified":"2014-01-29T10:47:20","modified_gmt":"2014-01-29T10:47:20","slug":"rasbperry-pi-gpio-pinout","status":"publish","type":"page","link":"https:\/\/warc.org.uk\/?page_id=1794","title":{"rendered":"Rasbperry Pi GPIO Pinout"},"content":{"rendered":"<p><a href=\"https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1789 alignleft\" alt=\"gpio\" src=\"https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio-300x283.jpg\" width=\"300\" height=\"283\" srcset=\"https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio-300x283.jpg 300w, https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio-158x150.jpg 158w, https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio-150x141.jpg 150w, https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio.jpg 462w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>RPi is a 3.3V device.<br \/>\nThe GPIO pins are unbuffered and unprotected, so if you short it out, you can destroy the RPi.<\/p>\n<p>GPIO I\/O Example:<\/p>\n<p><span style=\"color: #3366ff;\"># example1.py<\/span><br \/>\n<span style=\"color: #3366ff;\"> # Import the required module.<\/span> import RPi.GPIO as GPIO<\/p>\n<p><span style=\"color: #3366ff;\"># Set the mode of numbering the pins.<\/span> GPIO.setmode(GPIO.BOARD)<\/p>\n<p><span style=\"color: #3366ff;\"># GPIO pin 10 is the output.<\/span> GPIO.setup(10, GPIO.OUT) GPIO pin 8 is the input. GPIO.setup(8, GPIO.IN)<\/p>\n<p><span style=\"color: #3366ff;\"># Initialise GPIO10 to high (true) so that the LED is off.<\/span> GPIO.output(10, True) while 1: if GPIO.input(8): GPIO.output( 10, False) else:<\/p>\n<p><span style=\"color: #3366ff;\"># When the button switch is not pressed, turn off the LED.<\/span> GPIO.output( 10, True)<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1805 alignleft\" alt=\"gpio2\" src=\"https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio2-297x300.jpg\" width=\"297\" height=\"300\" srcset=\"https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio2-297x300.jpg 297w, https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio2-148x150.jpg 148w, https:\/\/warc.org.uk\/wp-content\/uploads\/2014\/01\/gpio2.jpg 318w\" sizes=\"auto, (max-width: 297px) 100vw, 297px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>I2C I\/O Example: PCF8574A 8-bit I\/O Expander for I2C BUS<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\"># example2.py import smbus <\/span><\/p>\n<p><span style=\"color: #3366ff;\"># Access the i2c bus now.<\/span> bus = smbus.SMBus(0)<\/p>\n<p><span style=\"color: #3366ff;\"># Now write 1 to the device with the address 56, turn off the LED by setting pin 0 to 1, and reset the switch by switching pin 1 to 0.<\/span> bus.write_byte(56, 1) while 1:<\/p>\n<p><span style=\"color: #3366ff;\"># If the button is pressed, pin 1 will be 1 and the byte read from the device with address 56 will be 00000010 (2) or 0000000011 (3).<\/span> if bus.read_byte(56) in (2,3):<\/p>\n<p><span style=\"color: #3366ff;\"># Write 00000000, setting pin 0 to 0, turning on the LED, and resetting the switch with pin 1 to 0.<\/span> bus.write_byte(56, 0) else:<\/p>\n<p><span style=\"color: #3366ff;\"># Write 00000010, setting pin 0 to 1, turning off the LED, and pin 1 to 0 to reset the switch.<\/span> bus.write_byte(56, 1)<\/p>\n<p>&nbsp;<\/p>\n<p><a title=\"APRS I-Gate (the PiGate)\" href=\"https:\/\/warc.org.uk\/?page_id=1808\">Now onto some interesting stuff!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RPi is a 3.3V device. The GPIO pins are unbuffered and unprotected, so if you short it out, you can destroy the RPi. GPIO I\/O Example: # example1.py # Import the required module. import RPi.GPIO as GPIO # Set the mode of\u2026<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/warc.org.uk\/?page_id=1794\">Continue reading<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":98,"featured_media":0,"parent":1762,"menu_order":2,"comment_status":"open","ping_status":"open","template":"templates\/template-page-with-intro.php","meta":{"footnotes":""},"class_list":["post-1794","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/warc.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/1794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/warc.org.uk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/warc.org.uk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/warc.org.uk\/index.php?rest_route=\/wp\/v2\/users\/98"}],"replies":[{"embeddable":true,"href":"https:\/\/warc.org.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1794"}],"version-history":[{"count":12,"href":"https:\/\/warc.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/1794\/revisions"}],"predecessor-version":[{"id":1822,"href":"https:\/\/warc.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/1794\/revisions\/1822"}],"up":[{"embeddable":true,"href":"https:\/\/warc.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/1762"}],"wp:attachment":[{"href":"https:\/\/warc.org.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}