<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://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>Change the state of a LED when there is a rising edge of a button</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74288/change-the-state-of-a-led-when-there-is-a-rising-edge-of-a-button</link><description>Hi, 
 
 I am trying to change the state of a LED whenever there is a rising edge of a button 
 
 Here is my code : 
 
 
 When I build, I have this error : 
 
 
 By the way, I am not sure if 
 nrfx_gpiote_in_init(SW0_GPIO_PIN, &amp;amp;configinterruption , input_pin_handle</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Apr 2021 14:31:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74288/change-the-state-of-a-led-when-there-is-a-rising-edge-of-a-button" /><item><title>RE: Change the state of a LED when there is a rising edge of a button</title><link>https://devzone.nordicsemi.com/thread/306157?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 14:31:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d42144f4-74d0-433f-92ab-ed38445f56fa</guid><dc:creator>Ali Rumane</dc:creator><description>&lt;p&gt;As suggested by&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/awneil"&gt;awneil&lt;/a&gt;, I think code won&amp;#39;t even compile.&lt;/p&gt;
&lt;p&gt;Here is a code you can try. You may not need&amp;nbsp;&lt;em&gt;nrf_gpio_pin_read&lt;/em&gt; since &lt;em&gt;gpiote&lt;/em&gt; it is configured for rising edge, see what works.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define BUTTON 4


void input_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
	if (pin == BUTTON)
    {
		if (nrf_gpio_pin_read(BUTTON))
		{
			// High state
		}
		else
		{
			// Low state
		}
	}
}


static void gpiote_init(void)
{
    ret_code_t err_code;

    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }

	nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config = NRF_GPIO_PIN_PULLDOWN;

    err_code = nrf_drv_gpiote_in_init(BUTTON, &amp;amp;in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);
	
	nrf_drv_gpiote_in_event_enable(BUTTON, true);
}

int main(void)
{
    ..
    ..
    gpiote_init();
    ..
    ..
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Change the state of a LED when there is a rising edge of a button</title><link>https://devzone.nordicsemi.com/thread/306153?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 14:23:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ed8c83c-36f4-475a-87c2-355f33859e8d</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;The C programming language does not allow executable statements outside functions:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
nrfx_gpiote_in_config_t  configinterruption = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
configinterruption.pull =  NRF_GPIO_PIN_PULLUP;  &amp;lt;&amp;lt;--- THIS!

void input_pin_handle(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{   
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>