From 0271ffac525fed80e2f714ff29231d128eb4c40c Mon Sep 17 00:00:00 2001 From: nguyenchi3011 <144758729+nguyenchi3011@users.noreply.github.com> Date: Wed, 27 Sep 2023 20:43:33 +0700 Subject: [PATCH 1/3] NguyenHaiChi --- ex1.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ex1.c diff --git a/ex1.c b/ex1.c new file mode 100644 index 0000000..c228492 --- /dev/null +++ b/ex1.c @@ -0,0 +1,18 @@ + +#define pinLed 27 +#define button 19 + +void setup(){ + Serial.begin(115200); + pinMode(pinLed, OUTPUT); + pinMode(button, INPUT); +} +void loop(){ + int buttonMode=digitalRead(button); + if(buttonMode){ + digitalWrite(pinLed, LOW); + }else{ + digitalWrite(pinLed, HIGH); + } + delay(100); +} \ No newline at end of file From 17f7a0a21ad2de9de9a57981831dbc547bec196a Mon Sep 17 00:00:00 2001 From: nguyenchi3011 <144758729+nguyenchi3011@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:04:34 +0700 Subject: [PATCH 2/3] Update ex1.c --- ex1.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ex1.c b/ex1.c index c228492..aa648d5 100644 --- a/ex1.c +++ b/ex1.c @@ -1,18 +1,24 @@ +#define pinLed 25 +#define button 21 +int buttonMode=0; -#define pinLed 27 -#define button 19 +void IRAM_ATTR Interrupts(){ + buttonMode=digitalRead(button); +} void setup(){ Serial.begin(115200); pinMode(pinLed, OUTPUT); pinMode(button, INPUT); + attachInterrupt(digitalPinToInterrupt(button), Interrupts, CHANGE); + } void loop(){ - int buttonMode=digitalRead(button); + if(buttonMode){ digitalWrite(pinLed, LOW); }else{ digitalWrite(pinLed, HIGH); } delay(100); -} \ No newline at end of file +} From 73f15e03b99b63ac2900cca54f5b1e560c1f1871 Mon Sep 17 00:00:00 2001 From: nguyenchi3011 <144758729+nguyenchi3011@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:52:59 +0700 Subject: [PATCH 3/3] Chip_info --- chip_info.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 chip_info.c diff --git a/chip_info.c b/chip_info.c new file mode 100644 index 0000000..d248345 --- /dev/null +++ b/chip_info.c @@ -0,0 +1,40 @@ + +#include +#include +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_chip_info.h" +#include "esp_flash.h" + +void app_main(void) +{ + esp_chip_info_t chip_info; + + esp_chip_info(&chip_info); + printf(" ESP32 Chip Name: %s\n", CONFIG_IDF_TARGET); + printf(" ESP32 vesion:%s\n ", esp_get_idf_version()); + + + printf("This is ESP32 chip with %d CPU core(s) , WiFi%s%s, model:%d \n ", + chip_info.cores, + (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", + (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "", + chip_info.model ); + + unsigned major_rev = chip_info.revision / 100; + unsigned minor_rev = chip_info.revision % 100; + printf("ESP32 revision v%d.%d \n ", major_rev, minor_rev); + + printf("%s flash\n",(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "Embedded" : "External"); + + printf("Minimum free heap size: %ld PRIu32 bytes\n", esp_get_minimum_free_heap_size()); + + for (int i = 5; i >= 0; i--) { + printf("Restarting in %d seconds...\n", i); + vTaskDelay(1000 / portTICK_PERIOD_MS); + } + printf("Restarting now.\n"); + fflush(stdout); + esp_restart(); +}