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

nrf51822 Button Pull Up

Hi, I am working my way through the Nan 36 document and everything seems to be working fine. Have a question regarding Button Pullup.

Little confused on this piece of code:

static app_button_cfg_t buttons[] =
{
    {WAKEUP_BUTTON_PIN,       false, NRF_GPIO_PIN_PULLUP, NULL},
    {LEDBUTTON_BUTTON_PIN_NO, false, NRF_GPIO_PIN_PULLUP, button_event_handler},
};

I understand it to be that pull up would be enabled on the buttons. Which I thought it means when I press the button 01 is sent and then set to 00. So that when I press the button the second time the value is again 01. But currently I have to press the button the second time to set to 00 and then the third time to 01.

Could someone please explain it better ?

  • Hi John,

    The example works in the way that it stores the last state of the button in function "button_event_handler()". See variable "send_push".

    This means that each time you press the button, the button event handler will execute, send the "send_push" variable to the ble_lbs-handler, then invert the state of "send_push".

    This way you will get '0' first, then '1', then '0', and so on.

    Best regards Håkon

Related