define RELAY_PIN 22
void main(void) {
const struct device relay_device = device_get_binding(DT_LABEL(DT_NODELABEL(gpio)));
gpio_pin_configure(relay_device, RELAY_PIN, GPIO_OUTPUT);
while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
gpio_pin_set(relay_device, RELAY_PIN, 1);
k_sleep(K_SECONDS(10)); // Pump runs for 10 seconds
gpio_pin_set(relay_device, RELAY_PIN, 0);
}
k_sleep(K_MSEC(500));
}
}
define RELAY_PIN 22
void main(void) {
const struct device relay_device = device_get_binding(DT_LABEL(DT_NODELABEL(gpio)));
gpio_pin_configure(relay_device, RELAY_PIN, GPIO_OUTPUT);
while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
gpio_pin_set(relay_device, RELAY_PIN, 1);
k_sleep(K_SECONDS(10)); // Pump runs for 10 seconds
gpio_pin_set(relay_device, RELAY_PIN, 0);
}
k_sleep(K_MSEC(500));
}
}