This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

button function crashing the advertsing

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

main.c

Parents
  • 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.

    Example.

    EDIT: Updated example that starts advertising after 3 second push and stops advertising after 5 second push.

    main.c

    EDIT 2: Exmple with buttons and ble advertising:

    ble-button-timer.c

  • 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

Reply
  • 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

Children
No Data
Related