Search
🪨

3. sk68xxmini-hs LED 컨트롤(ESP32-S3-DevkitC-1 내장 LED)

회로 확인

GPIO48 → DIN
LED를 제어하려면 FastLED 또는 NeoPixel 라이브러리를 사용해야 함.

문제 확인

코드에서는 틀린것이 없어서 확인해보니 보드에 실크로 io38이라고 적여있음(사용하는 보드 확인 필요)
#include <Adafruit_NeoPixel.h>
JavaScript
복사
네오픽셀 라이브러리 필요

platformio.ini파일에 라이브러리 추가

adafruit/Adafruit NeoPixel @ ^1.10.7
JavaScript
복사

전체코드

#include <Arduino.h> #include <Adafruit_NeoPixel.h> // #define PIN 48 // GPIO48에 연결된 LED #define PIN 38 // GPIO48에 연결된 LED #define NUMPIXELS 1 // LED 개수 Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ400); void turn_on_red() { Serial.println("빨간색 시도"); pixels.clear(); pixels.setPixelColor(0, pixels.Color(255, 0, 0)); pixels.show(); } void turn_on_green() { Serial.println("초록색 시도"); pixels.clear(); pixels.setPixelColor(0, pixels.Color(0, 255, 0)); pixels.show(); } void turn_on_blue() { Serial.println("파란색 시도"); pixels.clear(); pixels.setPixelColor(0, pixels.Color(0, 0, 255)); pixels.show(); } void turn_on_white() { Serial.println("흰색 시도"); pixels.clear(); pixels.setPixelColor(0, pixels.Color(255, 255, 255)); pixels.show(); } void turn_off() { Serial.println("LED 끄기"); pixels.clear(); pixels.setPixelColor(0, pixels.Color(0, 0, 0)); pixels.show(); } void setup() { Serial.begin(115200); delay(1000); Serial.println("NeoPixel 테스트 시작"); // 높은 밝기로 설정 pixels.begin(); pixels.setBrightness(10); // 최대 밝기 } void loop() { turn_on_red(); delay(1000); turn_on_green(); delay(1000); turn_on_blue(); delay(1000); turn_on_white(); delay(1000); turn_off(); delay(1000); }
C++
복사