28 lines
629 B
C
28 lines
629 B
C
#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;
|
|
}
|
|
}
|