1
1

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(1kHz,0%...100%)で遊ぶ。

1
Posted at

M5Stapm S3でPWM(1kHz,0%...100%)で遊ぶ。

Arduino PWM サーボモータ M5stack

x 過去ログを見よ!!

結果

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

o_coq508.jpg

プログラム



//PWM_ledcWrite_test_1khz_StampS3_1

#define PWM_PIN 15
#define FREQUENCY 1000
#define RESOLUTION 8

//初期化
void setup() {

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

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


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

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

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

    delay(20); //20ms待つ

  } //for i

} //loop



1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?