{"id":95,"date":"2020-09-04T03:13:37","date_gmt":"2020-09-04T03:13:37","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=95"},"modified":"2021-07-14T00:38:58","modified_gmt":"2021-07-14T00:38:58","slug":"normal-open-switches","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=95","title":{"rendered":"Normal Open Switches"},"content":{"rendered":"\n<p><strong>Normal Open Switches&nbsp;<\/strong><\/p>\n\n\n\n<p>Normal \u2013 Open switches is the name given to the switches we are very much used to. The switches that turn on when we press and goes off when we release. These switches are called Normal-Open because in their normal state they behave like an open circuit. It is &nbsp;by pressing the switch that we actually close the circuit. This behavior is contrary to that of Normal-Close switches. To learn more about Normal- Close switches please see&nbsp;<a href=\"http:\/\/cortex-m.com\/normal-close-switches\/\">this lesson<\/a>. See the circuit diagram and example source code\u2019s link &nbsp;below.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bohobiom.com\/wp-content\/uploads\/2020\/01\/NO_Switch.jpg\" alt=\"\" width=\"580\" height=\"464\"\/><\/figure>\n\n\n\n<p><strong>Connecting a Normal Open switch to a microcontroller<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Enable the clock of the GPIO pin<\/li><li>Set GPIO pin as input<\/li><li>Enable internal Pull-down resistor for GPIO pin<\/li><\/ol>\n\n\n\n<p>Two programs are presented in this example page. The first program is an example of connecting Normal-Close switches to the TM4C Tiva C Launchpad while the second example talks about connecting Normal-Open switches to the same microcontroller.<\/p>\n\n\n\n<p><strong>Program 1 : Normal-Close Switches&nbsp;<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&lt;br&gt;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/Function : Demonstrates how NC switches work\n \n#include &quot;TM4C123.h&quot; \/\/ Device header\n#include&lt;stdint.h&gt;\n \n#define BLUE_LED (1U&lt;&lt;2)\n#define NC_Switch (1U&lt;&lt;4) int main() { SYSCTL-&gt;RCGCGPIO |=(1U&lt;&lt;0); SYSCTL-&gt;RCGCGPIO |=(1U&lt;&lt;5); GPIOF-&gt;DIR |= BLUE_LED;\nGPIOF-&gt;DEN |= BLUE_LED;\nGPIOA-&gt;PUR |= NC_Switch;\nGPIOA-&gt;DEN |= NC_Switch;\n \nwhile(1)\n{\nif((GPIOA -&gt; DATA &amp; NC_Switch) !=0)\nGPIOF-&gt;DATA |=BLUE_LED;\nelse\nGPIOF -&gt; DATA &amp;= ~BLUE_LED;\n}\n \n}<\/pre><\/div>\n\n\n\n<p><strong>Program 2 : Normal-Open Switches&nbsp;<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&lt;br&gt;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/Function : Demonstrates how NO switches work\n \n#include &quot;TM4C123.h&quot; \/\/ Device header\n#include&lt;stdint.h&gt;\n \n#define BLUE_LED (1U&lt;&lt;2)\n#define NO_Switch (1U&lt;&lt;4) int main() { SYSCTL-&gt;RCGCGPIO |=(1U&lt;&lt;0); SYSCTL-&gt;RCGCGPIO |=(1U&lt;&lt;5); GPIOF-&gt;DIR |= BLUE_LED;\nGPIOF-&gt;DEN |= BLUE_LED;\nGPIOA-&gt;PDR |= NO_Switch;\nGPIOA-&gt;DEN |= NO_Switch;\n \nwhile(1)\n{\nif((GPIOA -&gt; DATA &amp; NO_Switch) !=0)\nGPIOF-&gt;DATA |=BLUE_LED;\nelse\nGPIOF -&gt; DATA &amp;= ~BLUE_LED;\n}\n \n}<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Normal Open Switches&nbsp; Normal \u2013 Open switches is the name given to the switches we are very much used to. The switches that turn on when we press and goes off when we release. These switches are called Normal-Open because in their normal state they behave like an open circuit. It is &nbsp;by pressing the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[10],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-peripheral-drivers","tag-peripheral-drivers"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/95"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=95"}],"version-history":[{"count":4,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}