I am trying to read an analog value on the GPIO port into my application. Looking through the examples, there aren't any that help solve this problem as the ADC example is only for the NRF51.
I am trying to read a sensor value connected to the board and I am utilizing the schematic shown here for my initial learning process: www.sparkfun.com/.../389
The 5V and GND are corrected accordingly and the analog input is connected to P0.03 (A0) on my board. I modified the "/examples/peripheral/bsp/" code to include GPIO functionality. First I added:
#include "nrf_gpio.h"
#include <inttypes.h>
#define PORT_NUM 3
Then I added:
static void gpio_init(void)
{
nrf_gpio_cfg_input(PORT_NUM, NRF_GPIO_PIN_NOPULL);
}
In the "bsp_evt_handler" I added this to the bottom:
uint32_t pin_value = 0;
uint8_t port_value = 0;
pin_value = nrf_gpio_pin_read(PORT_NUM);
port_value = nrf_gpio_port_read(PORT_NUM);
printf("pin value: %zu\n\r", pin_value);
printf("port value: %zu\n\r", port_value);
printf("port value: %" PRIu8 " \n\r", port_value);
And in the main function above uart_init(); I added:
gpio_init();
A full source code is at this pastebin: http://pastebin.com/zZXR0EU6
Whenever I am reading the UART, the value is always 0. No matter if I am pressing the sensor down or not. What could be the issue here?