Toolbox.NETMF.Hardware.BitBangBuzzer


Toolbox.NETMF.Hardware.BitBangBuzzer(PortId, InitialState = false)
  • PortId The pin the buzzer is connected to
  • InitialState When true, the buzzer will make noise immediately

Methods

  • Write(Value) When value is true, it'll buzz, otherwise it won't
  • Read() Returns true when buzzing, false when it doesn't
  • Dispose() Frees the port used by the buzzer

Properties

  • Interval Defines the interval of the speaker in milliseconds

How to connect

Toolbox.NETMF.Hardware.BitBangBuzzer.png

Sample code in C#

// Defines the buzzer connected to pin 3 and ground
BitBangBuzzer Buzzer = new BitBangBuzzer(Pins.GPIO_PIN_D3);

// Infinite loop
while (true)
{
    // Lets make some noise for 5 seconds!
    Debug.Print("Cover your ears!");
    Buzzer.Write(true);
    Thread.Sleep(5000);
    // Lets be silent for a sec
    Debug.Print("Finally, some silence!");
    Buzzer.Write(false);
    Thread.Sleep(1000);
}

Sample code in VB

' Defines the buzzer connected to pin 3 and ground
Dim Buzzer As BitBangBuzzer = New BitBangBuzzer(Pins.GPIO_PIN_D3)

' Infinite loop
Do
    ' Lets make some noise for 5 seconds!
    Debug.Print("Cover your ears!")
    Buzzer.Write(True)
    Thread.Sleep(5000)
    ' Lets be silent for a sec
    Debug.Print("Finally, some silence!")
    Buzzer.Write(False)
    Thread.Sleep(1000)
Loop

Last edited Oct 4, 2011 at 4:51 PM by Garrcomm, version 2