Hi,
I'm using GPIO pin as input button with nrf9160 using Zephyr RTOS, but when I was press the button I didn't get any response from button state.
hear is my code
#include <zephyr/zephyr.h> #include <zephyr/device.h> #include <zephyr/drivers/gpio.h> #include <zephyr/sys/util.h> #include <zephyr/sys/printk.h> #include <inttypes.h> #define SLEEP_TIME_MS 1000 #define button 6 void main(void) { int ret; int count=0; int gpio_dev =device_get_binding("GPIO_0"); if(!gpio_dev) { printk("Cannot bind gpio device\n"); return 0; } ret = gpio_pin_configure(gpio_dev,button, GPIO_INPUT); printk("Press the button\n"); while (1) { int val = gpio_pin_get(gpio_dev,button); if (val!= 0) { count=0; } count++; printk("count =%d\n",count); k_msleep(SLEEP_TIME_MS); } }
when I press button count value not changing, if anyone know where I did wrong please help me to solve this.
thank you