<?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>Led blink using buttons in nrf52840 development board.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53196/led-blink-using-buttons-in-nrf52840-development-board</link><description>Hi, 
 I am using nordic semiconductor nrf52840 development board and segger embedded studio. I want to write a code to switch on led when button is pressed. Is there an example available? 
 Thanks.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Oct 2019 08:31:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53196/led-blink-using-buttons-in-nrf52840-development-board" /><item><title>RE: Led blink using buttons in nrf52840 development board.</title><link>https://devzone.nordicsemi.com/thread/214748?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 08:31:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68cc1c8c-e637-41ea-812a-ad54a8f52c1d</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I suggest you start with the&amp;nbsp;&lt;a title="Blinky Example" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/gpio_example.html?cp=5_1_4_6_0"&gt;Blinky Example&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a title="Timer Example" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/nrf_dev_timer_example.html?cp=5_1_4_6_46"&gt;Timer Example&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Both use the&amp;nbsp;&lt;a title="Board Support Package (BSP)" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_bsp.html?cp=5_1_3_6"&gt;Board Support Package (BSP)&lt;/a&gt;&amp;nbsp;who&amp;#39;s controlling LED&amp;#39;s and buttons, but for controlling a GPIO directly I suggest you read the&amp;nbsp;&lt;a title="GPIO HAL" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__gpio__hal.html?cp=5_1_6_9_0_11_0"&gt;GPIO HAL API&lt;/a&gt;&amp;nbsp;and the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/gpio.html?cp=3_0_0_5_8"&gt;GPIO — General purpose input/output&lt;/a&gt;&amp;nbsp;specification. See examples for GPIO usage in the BSP library.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For pin number larger than 31, ie. PORT 1, use&amp;nbsp;&lt;a title="NRF_GPIO_PIN_MAP" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__gpio__hal.html?cp=5_1_6_9_0_11_0_0#ga0d66f2aaf7771ca4424237174032bf6a"&gt;NRF_GPIO_PIN_MAP&lt;/a&gt;, f.ex:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define LED_PIN NRF_GPIO_PIN_MAP(1, 5) // Use Port1 pin5 (p1.5)

nrf_gpio_cfg_output(LED_PIN);   // Configure pin as output

nrf_gpio_pin_set(LED_PIN);      // Set high
nrf_gpio_pin_clear(LED_PIN);    // Set low
nrf_gpio_pin_toggle(LED_PIN);   // Toggle state&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>