ButtonLED Dev

This commit is contained in:
2025-01-30 16:46:21 -08:00
parent cc7b79b9e6
commit 1739499817
1391 changed files with 145106 additions and 0 deletions

View File

@ -0,0 +1,6 @@
idf_component_register(
SRCS "Main.c"
PRIV_REQUIRES spi_flash
INCLUDE_DIRS ""
PRIV_REQUIRES esp_driver_gpio
)

27
ButtonLED/main/Main.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#define LED_GPIO 7
#define BUTTON_GPIO 1
void app_main(void) {
// Set led pin to output
gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT);
// Set button to input
gpio_set_direction(BUTTON_GPIO, GPIO_MODE_INPUT);
while(1) {
if (gpio_get_level(BUTTON_GPIO) == 1) {
printf("Trunning LED On/n");
gpio_set_level(LED_GPIO, 0);
} else {
printf("LED is off/n");
gpio_set_level(LED_GPIO, 1);
}
vTaskDelay(100);
return;
}
}