include <zephyr.h>
include <device.h>
include <drivers/gpio.h>
define PIR_SENSOR_PIN 23
void main(void) {
const struct device pir_device = device_get_binding(DT_LABEL(DT_NODELABEL(gpio)));
gpio_pin_configure(pir_device, PIR_SENSOR_PIN, GPIO_INPUT);
while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
// Motion detected
printk("Motion Detected!\n");
}
k_sleep(K_MSEC(500));
}
}
include <zephyr.h>
include <device.h>
include <drivers/gpio.h>
define PIR_SENSOR_PIN 23
void main(void) {
const struct device pir_device = device_get_binding(DT_LABEL(DT_NODELABEL(gpio)));
gpio_pin_configure(pir_device, PIR_SENSOR_PIN, GPIO_INPUT);
while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
// Motion detected
printk("Motion Detected!\n");
}
k_sleep(K_MSEC(500));
}
}