nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BUTTON PULLDOWN QUESTION

hello. I want to use the button as a pull-down.
I am using nrf52832, and the button and circuit part are composed of pull-down and the code is written as follows.

#define LED_RED 17
#define LED_GREEN  18

int main(void)
{
    nrf_gpio_cfg_output(LED_RED); 
    nrf_gpio_cfg_output(LED_GREEN);
    nrf_gpio_cfg_input(14, NRF_GPIO_PIN_PULLDOWN);
    
    for(;;)
    {
        if(nrf_gpio_pin_read(14) == 1)
        {
            nrf_gpio_pin_clear(LED_RED);
            nrf_gpio_pin_set(LED_GREEN);
        }
        else
        {
            nrf_gpio_pin_clear(LED_GREEN);
            nrf_gpio_pin_set(LED_RED);
        }
    }
}

However, even if the button is pressed, it always behaves as 0.
I want to know why...

Ask for help.

Parents Reply Children
No Data
Related