我有一个 Windows IOT 核心应用程序,它将输出写入 GPIO 引脚,我需要在三个引脚上设置可变电压,以将 RGB 灯设置为任何颜色。
问题是我只能将引脚设置为高值或低值,不能介于两者之间:
private void SetupLeds()
{
var gpio = GpioController.GetDefault();
_redLED = gpio.OpenPin(18);
_redLED.SetDriveMode(GpioPinDriveMode.Output);
_greenLED = gpio.OpenPin(23);
_greenLED.SetDriveMode(GpioPinDriveMode.Output);
_blueLED = gpio.OpenPin(24);
_blueLED.SetDriveMode(GpioPinDriveMode.Output);
}
public void Yellow()
{
_redLED.Write(GpioPinValue.High);
_greenLED.Write(GpioPinValue.High);
_blueLED.Write(GpioPinValue.Low);
}
public void Red()
{
_redLED.Write(GpioPinValue.High);
_greenLED.Write(GpioPinValue.Low);
_blueLED.Write(GpioPinValue.Low);
}
如果有人能指出正确的方向,以便能够在引脚上写入 1 到 0 之间的值,我将不胜感激。
也许这个版本的 Core IOT 甚至不可能。
更新
感谢 leppie 的评论,我现在意识到我当然需要使用 PWM。
现在的问题是有人知道如何在 Windows Core IOT 上使用 PWM 吗?
最佳答案
目前不支持 PWM。我期待它出现在以后的版本中。同时,您可以将 RPi2 连接到 Arduino。您可以访问 Arduino 上的 PWM。请参阅this sample in the file ControlPage.xaml.cs .
马克·拉德伯恩 [MSFT]
关于c# - GPIO windows IOT Core 的可变电压,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30920719/