Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIO pin mapping issue in nRF52840 PDK

I'm fairly new to nRF ecosystem and embedded studio. I'm just trying to read GPIO read of my digital hall sensor. Can anyone find what am I doing wrong with my code? I just modified the example blinky code. I've connected the sensor in P0.10

#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "boards.h"
#include "nrf_gpio.h"

 
 uint32_t j;
 #define sensor           10   
// #define sensor NRF_GPIO_PIN_MAP(0,10)

int main(void)
{
    /* Configure board. */
    bsp_board_leds_init();
    
    nrf_gpio_cfg_input(sensor,NRF_GPIO_PIN_NOPULL);
     
     

    /* Toggle LEDs. */
    while (true)
        {
            
           j = nrf_gpio_pin_read(sensor);
    
            printf("The value is: %d", j);
            nrf_delay_ms(500);

        if (j > 0)
          {

          bsp_board_led_on(0);
          nrf_delay_ms(500);
            
          }

        }
}


Parents Reply Children
No Data
Related