Hi,
I am using nordic semiconductor nrf52840 development board and segger embedded studio. I want to write a code to switch on led when button is pressed. Is there an example available?
Thanks.
Hi,
I am using nordic semiconductor nrf52840 development board and segger embedded studio. I want to write a code to switch on led when button is pressed. Is there an example available?
Thanks.
I suggest you start with the Blinky Example and Timer Example.
Both use the Board Support Package (BSP) who's controlling LED's and buttons, but for controlling a GPIO directly I suggest you read the GPIO HAL API and the GPIO — General purpose input/output specification. See examples for GPIO usage in the BSP library.
For pin number larger than 31, ie. PORT 1, use NRF_GPIO_PIN_MAP, f.ex:
#define LED_PIN NRF_GPIO_PIN_MAP(1, 5) // Use Port1 pin5 (p1.5) nrf_gpio_cfg_output(LED_PIN); // Configure pin as output nrf_gpio_pin_set(LED_PIN); // Set high nrf_gpio_pin_clear(LED_PIN); // Set low nrf_gpio_pin_toggle(LED_PIN); // Toggle state