Skip to content

Commit 49d589f

Browse files
authored
Add I2S example for M5Core2 in readme (#237)
***NO_CI***
1 parent f82200d commit 49d589f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,26 @@ var pin5 = M5StickC.GpioController.OpenPin(36, PinMode.Output);
366366

367367
The M5Core, M5Core2, Fire and Atom Lite/Matrix exposes 2 DAC and you can access them thru the `Dac1` and `Dac2` properties. Refer to the [DAC documentation](https://github.com/nanoframework/System.Device.Dac) for more information.
368368

369+
### I2S (sound)
370+
371+
372+
On the M5Core2, wav files can be played using I2S by installing the package [nanoFramework.System.Device.I2s](https://github.com/nanoframework/System.Device.I2S).
373+
To play wav files on the M5Core2, use following initialization:
374+
375+
```csharp
376+
int bckPin = 12;
377+
int dataPin = 2;
378+
int wsPin = 0;
379+
I2sWavPlayer.Bus bus = I2sWavPlayer.Bus.One;
380+
var audioFile = "D:\\Variation-CLJ013901.wav";
381+
using (var player = new I2sWavPlayer(bus, audioFile, bckPin, dataPin, wsPin))
382+
{
383+
M5Core2.Power.Gpio2Value = PinValue.High; //speaker power on
384+
player.Play();
385+
M5Core2.Power.Gpio2Value = PinValue.Low; //speaker power off
386+
}
387+
```
388+
369389
### Led
370390

371391
The M5StickC/CPlus exposes a led. You can access it thru the `Led` property:

0 commit comments

Comments
 (0)