2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

M5Stapm S3でPWM(50Hz,0%...100%)で遊ぶ。(20ms)

2
Last updated at Posted at 2024-10-11

M5Stapm S3でPWM(50Hz,0%...100%)で遊ぶ

Arduino PWM サーボモータ M5stack M5StampS3

結果

わからないと思うけど いろいろ、準備するのがめんどい

o_coq509.jpg

プログラム



//PWM_ledcWrite_test_50hz_StampS3_1

#define PWM_PIN 15
#define FREQUENCY 50
#define RESOLUTION 12

//初期化
void setup() {

  //出力ピンの初期化
  pinMode(PWM_PIN, OUTPUT);

  // PWM設定(ピン番号, 周波数, 分解能)
  ledcAttach(PWM_PIN, FREQUENCY, RESOLUTION);
  
} //setup


//メインループ
void loop() {

  //4096回繰り返す
  for (int i = 0; i < 4096; i++) {

    // DUTY比を指定して、チャンネルに対して実行
    ledcWrite(PWM_PIN, i);

    delay(5); //5ms待つ

  } //for i

} //loop


2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?