<?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 the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9403/how-the-change-the-outcome-of-a-button-press-action-in-nrf51-dk-using-app_button</link><description>Hello! 
 I just want to change the outcome of Button 1 press action in my nRF 51 Dk. For example, instead of toggling led 1, I want to toggle pin 5. How to actually do that? I fiddled with the code, but up to now, no advance. 
 P.s.: I am using ble_app_hrs_c</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Sep 2015 12:46:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9403/how-the-change-the-outcome-of-a-button-press-action-in-nrf51-dk-using-app_button" /><item><title>RE: How the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/thread/34691?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2015 12:46:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b68e36b1-a4d1-4508-8255-1822c782da8f</guid><dc:creator>F&amp;#225;vero</dc:creator><description>&lt;p&gt;Hello, Martin. Thanks for all sugestions. I fiddled with the code a little more and I think I managed to do what I want to do... Check my answer!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/thread/34690?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2015 12:43:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36352e69-2eae-496e-a798-e4a586e279e2</guid><dc:creator>F&amp;#225;vero</dc:creator><description>&lt;p&gt;My solution:&lt;/p&gt;
&lt;p&gt;What I did:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Searched in bsp_btn_ble.c the function advertising_buttons_configure().&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Commented line bsp_event_to_button_action_assign(BTN_ID_SLEEP, BTN_ACTION_SLEEP, BSP_EVENT_SLEEP);. Commenting this line will prevent led 1 from stop/start blinking - and the nRF51 DK to enter/exit sleep mode.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In main.c, function bsp_event_handler(), I expanded the switch statement to contain case BSP_EVENT_KEY_0. The BSP_EVENT_KEY_0 word is the default event passed to bsp_event_handler() when a button is pressed. So, the resulting code is:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;/* ...before cases */&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;	case BSP_EVENT_KEY_0:

		nrf_gpio_cfg_output(5);

		nrf_gpio_pin_toggle(5);

		break; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;/* ... after cases */&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a little unpolished code edit, but for a first approach/learning, its OK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/thread/34689?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2015 12:10:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc6fa7df-5678-4031-9977-c28f15c83779</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;First of all, the example is using the Button Support Package (BSP) library. This is a great library if you don&amp;#39;t want to control the LEDs and buttons yourself. However, things can get very complicated if you &lt;em&gt;do&lt;/em&gt; want to use BSP and control the LEDs and buttons yourself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;First (and poor) solution:&lt;/strong&gt; The BSP uses the pin definitions found in the header file pca10028.h. So what you can do is to change the pin defines here. E.g. change&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define BSP_LED_0_MASK (1&amp;lt;&amp;lt;BSP_LED_0)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define BSP_LED_0_MASK (1&amp;lt;&amp;lt;5)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This should make pin 5 toggle instead of LED_1 (remember to configure pin 5 as an output). This is not a very smart way to do it though, as changing pca10028.h will affect all your examples and code located in the SDK because all of the examples read the definitions in this very header file. The BSP module will not work as intended either.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Second (and better) solution:&lt;/strong&gt; Make your own header file containing all the defines found in pca10028 and change the defines you need. Then use this file instead of the original. This solution will still affect the BSP module as well.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Third (and maybe the best) solution:&lt;/strong&gt; Remove all BSP related code in the example and make all the code yourself (maybe using the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/lib_button.html?cp=4_1_0_3_5"&gt;app_button&lt;/a&gt; library). This is the best way, but requires you to do some work  on your own.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fourth (possible) solution:&lt;/strong&gt; I don&amp;#39;t have the time to do research on this solution, but it might be possible to use the BSP together with some PPI/GPIOTE code to make the blinking LED trigger an event that causes pin 5 toggle. Have a look at the example I posted in &lt;a href="https://devzone.nordicsemi.com/question/49193/invert-port-at-a-nrf51822/"&gt;this relevant thread&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/thread/34686?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2015 11:17:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc42440f-ecad-4579-a37d-9bde9980e6b4</guid><dc:creator>F&amp;#225;vero</dc:creator><description>&lt;p&gt;Hello, Martin. Thanks for the comment.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Yes! But I don&amp;#39;t know where in the code (file and code line) to do that - neither how, as input push button uses gpiote + app_button + app_timer layers and I&amp;#39;m uncertain how everything comes together...&lt;/li&gt;
&lt;li&gt;This could be usefull to my application, but I don&amp;#39;t want to that now.&lt;/li&gt;
&lt;li&gt;Yes, sensor board = ble_app_hrs example. Sensor + Collector working fine in the boards.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/thread/34685?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2015 09:42:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d99ec15-194b-427a-a001-ec7f4540076c</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure if I understand what you want to do.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Do you want to change the LED blinking on the Collector board (as it is referred to in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/ble_sdk_app_hrc.html?cp=4_1_0_4_2_0"&gt;example documentation&lt;/a&gt;) that runs the &lt;em&gt;ble_app_hrs_c&lt;/em&gt; example?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do you want to connect a sensor board and make a button push on the collector board toggle a LED on the sensor board?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do you use a sensor board? If so what code are you running on this board?&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/thread/34688?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2015 21:05:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43fbf4d8-831e-4391-b627-f448e1b53960</guid><dc:creator>F&amp;#225;vero</dc:creator><description>&lt;p&gt;Hello, David, thanks for your answer.
I&amp;#39;m using ble_app_hrs_c example, I didn&amp;#39;t wrote the code. The example works fine, but I cannot find where in the code I should edit to change led 1 from blinking to pin 5 toggling.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How the change the outcome of a button press action in nRF51 DK using app_button?</title><link>https://devzone.nordicsemi.com/thread/34687?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2015 20:55:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff123aa5-eee3-4006-bd57-efb3725a1376</guid><dc:creator>David Smoot</dc:creator><description>&lt;p&gt;It always helps if you post code if you are having trouble making something work.&lt;/p&gt;
&lt;p&gt;But if I had to guess your problem, I would bet that you forgot to configure a pin as an output before trying to drive it.&lt;/p&gt;
&lt;p&gt;Look at the blinky example as the simplest possible piece of code and start there.  Look at how they first configure the pin as an output.  If that still does not help, try posting code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>