Skip to main content

Meadow.Foundation.Grove.Audio.Speaker

Speaker
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Grove.Audio.Speaker

Code Example

Speaker speaker;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

speaker = new Speaker(Device.Pins.D13);

return Task.CompletedTask;
}

public override async Task Run()
{
for (int i = 0; i < 5; i++)
{
Resolver.Log.Info("Playing A major triad starting at A4");
await speaker.PlayTone(new Frequency(440, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //A
await speaker.PlayTone(new Frequency(554.37f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //C#
await speaker.PlayTone(new Frequency(659.25f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //E

await Task.Delay(2500);
}
}

Sample project(s) available on GitHub

Wiring Example

SpeakerMeadow Pin
GNDGND
VCC3.3V
RXD01

Class Speaker

Represents a Speaker

Assembly: Speaker.dll
View Source
Declaration
public class Speaker : PiezoSpeaker, IToneGenerator, IDisposable

Inheritance: System.Object -> Meadow.Foundation.Audio.PiezoSpeaker

Implements:
Meadow.Peripherals.Speakers.IToneGenerator, System.IDisposable

Implements

  • Meadow.Peripherals.Speakers.IToneGenerator
  • System.IDisposable