<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>problem with GPIO pin as input  with  nrf9160 using zephyr RTOS</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/88976/problem-with-gpio-pin-as-input-with-nrf9160-using-zephyr-rtos</link><description>Hi, 
 I&amp;#39;m using GPIO pin as input button with nrf9160 using Zephyr RTOS, but when I was press the button I didn&amp;#39;t get any response from button state. 
 hear is my code 
 
 when I press button count value not changing, if anyone know where I did wrong</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Wed, 15 Jun 2022 12:38:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/88976/problem-with-gpio-pin-as-input-with-nrf9160-using-zephyr-rtos" /><item><title>RE: problem with GPIO pin as input  with  nrf9160 using zephyr RTOS</title><link>https://test-devzone.nordicsemi.com/thread/372575?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 12:38:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44940c1a-5e1e-4574-9e08-e42f8dd86c0a</guid><dc:creator>user114789</dc:creator><description>&lt;p&gt;Hi Depraz,&lt;/p&gt;
&lt;p&gt;I changed my code as you said ,after changing also I&amp;#39;m not getting any response form my button. if I changed pin config as&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt; &lt;/span&gt;ret = gpio_pin_configure( gpio_dev ,button, GPIO_PULL_UP); &amp;quot; then&amp;nbsp; its working fine in onboard&amp;nbsp; button. if I connect it to&amp;nbsp; external button&amp;nbsp; its not working. My external button is connected to nrf9160 as bellow figure.&lt;/p&gt;
&lt;p&gt;.&lt;img alt=" " src="https://test-devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/511568b6ce395f1b40000000.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;is their any changes i have to do in my code if&amp;nbsp; I connect&amp;nbsp; button externally to board?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problem with GPIO pin as input  with  nrf9160 using zephyr RTOS</title><link>https://test-devzone.nordicsemi.com/thread/372550?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 11:46:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b48a34ac-3f32-4703-947b-710fbe6e5182</guid><dc:creator>user93713</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;device_get_binding returns a &amp;quot;&lt;span class="k"&gt;&lt;span class="pre"&gt;const&lt;/span&gt;&lt;/span&gt;&lt;span class="w"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;span class="pre"&gt;struct&lt;/span&gt;&lt;/span&gt;&lt;span class="w"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a class="reference internal" title="device" href="https://docs.zephyrproject.org/3.0.0/reference/drivers/index.html#c.device"&gt;&lt;span class="n"&gt;&lt;span class="pre"&gt;device&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&amp;quot; so&amp;nbsp;&lt;span class="w"&gt;&lt;span&gt;&amp;nbsp;gpio_dev should be&amp;nbsp;declared as&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;const struct device *gpio_dev =device_get_binding(&amp;quot;GPIO_0&amp;quot;);&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;It is always good to look for returned value, so I would replace&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;	ret = gpio_pin_configure(gpio_dev,button, GPIO_INPUT);
&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;by&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;	ret = gpio_pin_configure(gpio_dev,button, GPIO_INPUT);
    if (ret != 0)
    {
        printk(&amp;quot;Error %d&amp;quot;, ret);
        return 1;
    }&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Can you retry with those changes ? If this is still not working, make sure to have CONFIG_GPIO=y in your config and that the dts has&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;gpio0 {
  status = &amp;quot;okay&amp;quot;;
};
&lt;/pre&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>