SigmaDelta

はじめに

SigmaDelta変調を利用して、LEDの明るさを変えます。

プログラム

setup()

1
2
3
4
5
6
7
8
void setup()
{
    //setup on pin 18, channel 0 with frequency 312500 Hz
    sigmaDeltaSetup(18,0, 312500);
    //initialize channel 0 to off
    sigmaDeltaWrite(0, 0);
}
 

sigmaDeltaSetup()を用いて、シグマデルタ変調の設定を行います。

ESP-WROOM-32では、機能を実現するチャネルと、そのチャネルをどのピンに割り当てるかを、ソフトウェアを使って設定することができます。18番ピンをチャネル0に割り当てます。

sigmaDeltaWrite()を用いて、チャネルに出力します。

loop()

 9
10
11
12
13
14
15
16
void loop()
{
    //slowly ramp-up the value
    //will overflow at 256
    static uint8_t i = 0;
    sigmaDeltaWrite(0, i++);
    delay(100);
}

sigmaDeltaWrite()を用いて、チャネルに出力します。

バージョン

Hardware:ESP-WROOM-32
Software:Arduino core for the ESP32 2.0.4

最終更新日

September 4, 2022

inserted by FC2 system