#include <stdio.h>
#include <pico/stdlib.h>
// Pinos dos componentes
#define BUTTON_A_PIN 5
#define BUTTON_B_PIN 6
#define RED_LED_PIN 12
#define GREEN_LED_PIN 13
#define BLUE_LED_PIN 11
void set_leds (bool red, bool green, bool blue){
gpio_put (RED_LED_PIN, red);
gpio_put (GREEN_LED_PIN, green);
gpio_put (BLUE_LED_PIN, blue);
}
int main() {
// Inicializa os LEDs como saídas
gpio_init(RED_LED_PIN);
gpio_set_dir(RED_LED_PIN, GPIO_OUT);
gpio_init(GREEN_LED_PIN);
gpio_set_dir(GREEN_LED_PIN, GPIO_OUT);
gpio_init(BLUE_LED_PIN);
gpio_set_dir(BLUE_LED_PIN, GPIO_OUT);
// Inicializa os botões como entradas com pull-down
gpio_init(BUTTON_A_PIN);
gpio_set_dir(BUTTON_A_PIN, GPIO_IN);
gpio_pull_down(BUTTON_A_PIN);
gpio_init(BUTTON_B_PIN);
gpio_set_dir(BUTTON_B_PIN, GPIO_IN);
gpio_pull_down(BUTTON_B_PIN);
while (true) {
if (gpio_get(BUTTON_A_PIN) && gpio_get(BUTTON_B_PIN))
{
set_leds (1,1,1);
}
else if (gpio_get(BUTTON_A_PIN))
{
set_leds (1,0,0);
}
else if (gpio_get(BUTTON_B_PIN))
{
set_leds (0,1,0);
}
else set_leds(0,0,0);
{
sleep_ms(100);
}
}
return 0;
}