Hello everyone
i want to create button fucntion press the button for 3 seconds and then it has to start advertsing but i have excuted the button fucntion but it si showing some errors in gpiote files so any suggestion or ideas will be helpful for me
Hello everyone
i want to create button fucntion press the button for 3 seconds and then it has to start advertsing but i have excuted the button fucntion but it si showing some errors in gpiote files so any suggestion or ideas will be helpful for me
I modified your code and made a very basic example for you. It starts a single-shot timer when you push a button. When the timer event occurs after 3 seconds the application checks whether the button is still pressed and lights a LED accordingly. See comments in code marked with "NORDIC". You can add another timer that can turn off the LED for after 5 seconds.
EDIT: Updated example that starts advertising after 3 second push and stops advertising after 5 second push.
EDIT 2: Exmple with buttons and ble advertising:
I modified your code and made a very basic example for you. It starts a single-shot timer when you push a button. When the timer event occurs after 3 seconds the application checks whether the button is still pressed and lights a LED accordingly. See comments in code marked with "NORDIC". You can add another timer that can turn off the LED for after 5 seconds.
EDIT: Updated example that starts advertising after 3 second push and stops advertising after 5 second push.
EDIT 2: Exmple with buttons and ble advertising:
Thank you so much for your help but i am trying to use only one button for both actions like press the button for three secondds then LED 1 turn on and press the same button for 5 sec it will turn off the LED so instead of two button configuration what can i modify to use one button can you suggest me? because am new to this part
static void timer_handler(void * p_context) { if(!nrf_gpio_pin_read(BUTTON_1)) nrf_gpio_pin_toggle(LED_1); // Toggle LED 1 if button 1 is still pressed else if(!nrf_gpio_pin_read(BUTTON_2)) nrf_gpio_pin_toggle(LED_2); // Toggle LED 2 if button 2 is still pressed nrf_gpio_pin_clear(LED_1); }
I can able to amanage now if press the button 1 for 3, sec LED 1 is turned on and if i press the button 2 for 5 sec thent he LED 2 is turned on but i am trying to clear the LED 1 when button 2 is pressed for 5 sec but it is not getting cleared i dont know why can you tell me what i need to change in the handler function
Hello martin i have attached the updated program int he main. c file , if i add the button fucntion in the main program then board is not advertsing but if i remove that function it is advertising can you verify my program what i went wrong in that?
The app timer library uses timers. Try to initiate and create your timers before you initiate and enable the buttons.
yeah i ahve added all the necessaty imers but i am not able to find where i am going wrong can you guide me and verify my code and tell me exactly what i have to do and where i have to do because its really bit confusing for me