jaredwolff
Devtree:
/ {
leds {
compatible = "gpio-leds";
ssr0: ssr_0 {
gpios = <&gpio0 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
label = "SSR";
};
buzz: buzz_0 {
gpios = <&gpio0 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
label = "Buzz";
};
};
Code:
static const struct gpio_dt_spec SSR_spec = GPIO_DT_SPEC_GET(DT_NODELABEL(ssr0), gpios);
static const struct gpio_dt_spec LED_spec = GPIO_DT_SPEC_GET(DT_NODELABEL(blue_led), gpios);
static const struct gpio_dt_spec BUZZER_spec = GPIO_DT_SPEC_GET(DT_NODELABEL(buzz), gpios);
void init_GPIO(void){
gpio_pin_configure_dt(&SSR_spec, GPIO_OUTPUT);
gpio_pin_configure_dt(&LED_spec, GPIO_OUTPUT);
gpio_pin_configure_dt(&BUZZER_spec, GPIO_OUTPUT);
}
void main(void){
gpio_pin_set_dt(&BUZZER_spec, 1);
k_msleep(5000);
gpio_pin_set_dt(&BUZZER_spec, 0);
gpio_pin_set_dt(&SSR_spec, 1);
}
I connect it to a npn transistor so p0.04 ‘SSR’ can switch on a solid state relay. And p0.01 to npn transistor to a buzzer. both transistors are on the ground side.
when i switched the pin from ssr to p0.01 and buzz to p0.04 p0.04 still was the only one working altough it was then init as buzz and not the previously working ssr.