以下の内容はhttps://shuzo-kino.hateblo.jp/entry/2024/07/22/222515より取得しました。


PlatformIO上m5stamp s3の環境構築メモ

実際のところ

ボードは "M5stack-stamps3"、
m5stackのような専用ライブラリはなく、"M5Unified"というのがあるので、これをつかう

fastLEDもついでに使うと、platformIO.iniのファイルはこんな感じになる

[env:m5stack-stamps3]
platform = espressif32
board = m5stack-stamps3
framework = arduino
lib_deps = 
	fastled/FastLED@^3.7.4
	m5stack/M5Unified@^0.1.16

前パネルのボタンを押しながら電源投入で、BootModeになります
これをやらないと、書き込みができません
私はこれで30分溶かしました
説明書はちゃんとみましょう

書き込み

動作確認用のファイルはこんな感じ。
起動時は青、ボタン押下は赤

#include <M5Unified.h>
#include <FastLED.h>

#define NUM_LEDS 1
#define LED_PIN 21  // The pin connected to the NeoPixel on M5Stamp S3

// Define the LED array
CRGB leds[NUM_LEDS];

// Define colors using CRGB directly
const CRGB MY_BLUE = CRGB(0, 0, 255);
const CRGB MY_RED = CRGB(255, 0, 0);

void setLEDColor(const CRGB& color) {
  // Set the color of the LED
  leds[0] = color;
  FastLED.show();
}

void setup() {
  // Initialize M5Unified
  auto cfg = M5.config();
  M5.begin(cfg);
  Serial.begin(9600); // Initialize Serial

  // Initialize FastLED
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(50);  // Set brightness (0-255)

  // Set initial LED color to blue
  setLEDColor(MY_BLUE);

  Serial.println("M5Stamp S3 LED and Button Sample using M5Unified and FastLED");
}

void loop() {
  M5.update();  // Update button state

  // Check if the button is pressed
  if (M5.BtnA.isPressed()) {
    // Button is pressed, set LED to red
    setLEDColor(MY_RED);
    Serial.println("Button pressed - LED is RED");
  } else {
    // Button is not pressed, set LED back to blue
    setLEDColor(MY_BLUE);
  }

  // Small delay to prevent too rapid checking
  delay(10);
}

参考もと

m5-docs




以上の内容はhttps://shuzo-kino.hateblo.jp/entry/2024/07/22/222515より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14