<?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>How can i stop execution of my program until button is pressed ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25481/how-can-i-stop-execution-of-my-program-until-button-is-pressed</link><description>Hi,
i am using ble_app_hrs_c_pca10056_s140(nRF52840) and i want to stop execution of my program and based on button press return i want to continue my program. 
 i am unable to find the function used for button press? 
 please Help me how to do it</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Sep 2017 11:34:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25481/how-can-i-stop-execution-of-my-program-until-button-is-pressed" /><item><title>RE: How can i stop execution of my program until button is pressed ?</title><link>https://devzone.nordicsemi.com/thread/100419?ContentTypeID=1</link><pubDate>Tue, 26 Sep 2017 11:34:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffa30d82-b93c-4d18-9f32-adc543d3a7d5</guid><dc:creator>Mathias</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Define your button in this method:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void buttons_init(void) {
    // Note: Array must be static because a pointer to it will be saved in the Button handler
    //       module.

    static app_button_cfg_t buttons[] =
    {
        {BUTTON_2, false, BUTTON_PULL, button_event_handler}
    };

    app_button_init(buttons, 1, BUTTON_DETECTION_DELAY); }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And define your event handler that you refer to in that method as well:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void button_event_handler(uint8_t pin_no,uint8_t button_action)
{
   // Stop or start execution
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then just call buttons_init() in your main.&lt;/p&gt;
&lt;p&gt;This is how I do it when using S130 on nRF51822 but I guess this kind of stuff is the same on your setup.&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>