public MainPage() { this.InitializeComponent(); GpioController = GpioController.GetDefault(); BuzzPin = GpioController.OpenPin(5); BuzzPin.SetDriveMode(GpioPinDriveMode.Output); BuzzPin.Write(GpioPinValue.High); LedPin = GpioController.OpenPin(6); LedPin.SetDriveMode(GpioPinDriveMode.Output); LedPin.Write(GpioPinValue.High); }
private async Task MorseToBeep(string morse) { foreach (var c in morse) { switch (c) { case '.': BuzzPin.Write(GpioPinValue.Low); LedPin.Write(GpioPinValue.Low); await Task.Delay(100); BuzzPin.Write(GpioPinValue.High); LedPin.Write(GpioPinValue.High); break; case '-': BuzzPin.Write(GpioPinValue.Low); LedPin.Write(GpioPinValue.Low); await Task.Delay(300); BuzzPin.Write(GpioPinValue.High); LedPin.Write(GpioPinValue.High); break; case '/': BuzzPin.Write(GpioPinValue.High); LedPin.Write(GpioPinValue.High); await Task.Delay(200); break; default: break; } await Task.Delay(50); } }