{"id":1831,"date":"2014-11-04T13:31:00","date_gmt":"2014-11-04T13:31:00","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=1831"},"modified":"2025-01-16T11:14:00","modified_gmt":"2025-01-16T11:14:00","slug":"io-pin-control-from-the-command-line","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/command-line\/io-pins-command-line\/io-pin-control-from-the-command-line","title":{"rendered":"IO pin control from the command line"},"content":{"rendered":"<h5><span style=\"color: #ff6600;\">:-( it looks like this page is no longer good for the lastest versions of RPi OS<\/span><\/h5>\n<h5>Elevate your permissions to root user to allow IO access<\/h5>\n<pre><code>\nsudo -i\n<\/code><\/pre>\n<h5>Setup to control pin as output<\/h5>\n<p>Substitute 23 in the following commands for your GPIO number (GPIO, not pin number)<\/p>\n<pre><code>\necho \"23\" &gt; \/sys\/class\/gpio\/export\necho \"out\" &gt; \/sys\/class\/gpio\/gpio23\/direction\n<\/code><\/pre>\n<h5>Control Output State<\/h5>\n<pre><code>\necho \"1\" &gt; \/sys\/class\/gpio\/gpio23\/value\necho \"0\" &gt; \/sys\/class\/gpio\/gpio23\/value\n<\/code><\/pre>\n<h5>Setup to read pin as an input<\/h5>\n<p>Substitute 23\u00a0in the following commands for your GPIO number (GPIO, not pin number)<\/p>\n<pre><code>\necho \"23\" &gt; \/sys\/class\/gpio\/export\necho \"in\" &gt; \/sys\/class\/gpio\/gpio23\/direction\n<\/code><\/pre>\n<h5>Read its state<\/h5>\n<pre><code>\ncat \/sys\/class\/gpio\/gpio23\/value\n<\/code><\/pre>\n<h4>To Release A Pin Afterwards<\/h4>\n<pre><code>\necho \"23\" &gt; \/sys\/class\/gpio\/unexport\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>:-( it looks like this page is no longer good for the lastest versions of RPi OS Elevate your permissions to root user to allow IO access sudo -i Setup to control pin as output Substitute 23 in the following commands for your GPIO number (GPIO, not pin number) echo &#8220;23&#8221; &gt; \/sys\/class\/gpio\/export echo &#8220;out&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[91],"tags":[],"class_list":["post-1831","post","type-post","status-publish","format-standard","hentry","category-io-pins-command-line"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1831","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=1831"}],"version-history":[{"count":3,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1831\/revisions"}],"predecessor-version":[{"id":3824,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1831\/revisions\/3824"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=1831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=1831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=1831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}