{"id":23,"date":"2013-10-24T14:43:33","date_gmt":"2013-10-24T14:43:33","guid":{"rendered":"https:\/\/arduino-developer.com\/arduino\/?p=23"},"modified":"2020-10-22T12:57:28","modified_gmt":"2020-10-22T11:57:28","slug":"general-io-pins","status":"publish","type":"post","link":"https:\/\/arduino-developer.com\/arduino\/programming\/io-pins\/general-io-pins","title":{"rendered":"General IO Pins"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Setup Pin Mode <\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  pinMode(13, OUTPUT);     \n  pinMode(12, INPUT);\n  pinMode(12, INPUT_PULLUP);    \/\/Input with pullup resistor<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Set Outputs <\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  digitalWrite(13, HIGH);\n  digitalWrite(13, LOW);\n\n  digitalWrite(13, 1);\n  digitalWrite(13, 0);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Read Inputs<br><\/h4>\n\n\n\n<p>Using a variable: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  int MyInputState;\n  \n  MyInputState = digitalRead(3);\n  if (MyInputState == HIGH)\n    DoSomething();<\/code><\/pre>\n\n\n\n<p>Using directly: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  if (digitalRead(3))\n    DoSomething();<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Analog Pins As General IO <\/h4>\n\n\n\n<p>The analog pins can be used identically to the digital pins, using the aliases A0, A1, etc. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  pinMode(A0, OUTPUT);\n  digitalWrite(A0, HIGH);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Device Pin Numbers<\/h4>\n\n\n\n<p>You should always use Arduino pin numbers (e.g. 1, 2, 3, A0, A1, A2) and not device port pin numbers (e.g. PA0, PA1, PB0, PB1).<\/p>\n\n\n\n<p>Whilst you may get things to work using port numbers, it can trip you up (e.g. ATtiny841 PA pin numbers working but PB pin numbers not)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setup Pin Mode Set Outputs Read Inputs Using a variable: Using directly: Analog Pins As General IO The analog pins can be used identically to the digital pins, using the aliases A0, A1, etc. Device Pin Numbers You should always use Arduino pin numbers (e.g. 1, 2, 3, A0, A1, A2) and not device port [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-io-pins"],"_links":{"self":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":8,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":620,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/23\/revisions\/620"}],"wp:attachment":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}