Created
May 15, 2024 06:33
-
-
Save penpencool/43c39b0139986a1643a957810913840a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void showESPInfo() { | |
| Serial.println("AllNewStep TESTER"); | |
| Serial.println( "Hardware Info..." ); | |
| Serial.printf( "- ESP chip model : %s\n", | |
| ESP.getChipModel() ); | |
| Serial.printf( "- Chip revision : %u\n", | |
| ESP.getChipRevision() ); | |
| Serial.printf( "- No. of cores : %u\n", | |
| ESP.getChipCores() ); | |
| Serial.printf( "- Chip MAC address : %llx\n", | |
| ESP.getEfuseMac() ); | |
| Serial.printf( "- Total heap size : %lu bytes\n", | |
| ESP.getHeapSize() ); | |
| Serial.printf( "- Free heap size : %lu bytes\n", | |
| ESP.getFreeHeap() ); | |
| Serial.printf( "- Total PSRAM size : %lu bytes\n", | |
| ESP.getPsramSize() ); | |
| Serial.printf( "- Free PSRAM size : %lu bytes\n", | |
| ESP.getFreePsram() ); | |
| Serial.printf( "- SPI flash size : %lu MB\n", | |
| ESP.getFlashChipSize()/(1024*1024) ); | |
| Serial.printf( "- SPI flash speed : %lu MHz\n\n", | |
| ESP.getFlashChipSpeed()/(long)1e6 ); | |
| Serial.println( "Software Info..." ); | |
| #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) | |
| Serial.printf( "- Arduino ESP32 Core : v%s\n", | |
| ESP.getCoreVersion() ); | |
| #else | |
| Serial.printf( "- Arduino ESP32 Core : v%i.%i.%i\n", | |
| ESP_ARDUINO_VERSION_MAJOR, | |
| ESP_ARDUINO_VERSION_MINOR, | |
| ESP_ARDUINO_VERSION_PATCH ); | |
| #endif | |
| Serial.printf( "- Espressif ESP-IDF : %s\n\n", | |
| ESP.getSdkVersion() ); | |
| } | |
| void setup() { | |
| Serial.begin( 115200 ); | |
| Serial.println("\n\n\n"); | |
| } | |
| void loop() { | |
| showESPInfo(); | |
| delay(5000); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
โค้ดตัวอย่างไฟ LED WS2812
#include <Adafruit_NeoPixel.h>
#define PIN 8 // ขาที่ใช้ต่อกับ LED
#define NUM_LEDS 1 // จำนวน LED ที่ใช้
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
Serial.println("AllNewStep.com TEST OK.");
strip.begin(); // เริ่มต้นไลบรารี
strip.show(); // ตั้งค่าเริ่มต้น (ปิดทุก LED)
}
void loop() {
rainbowCycle(10); // เรียกฟังก์ชันทำสีรุ้ง (ความเร็ว)
}
// ฟังก์ชันแสดงสีรุ้ง
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on the wheel
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
// ฟังก์ชันแปลงค่าจาก 0-255 เป็นสี
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}