[英]How to read or control a pin from different thread in C# and Raspberry Pi
[英]how to read value from GPIO5 pin of Raspberry PI 3 using C#?
我使用Q4XTBLAF300-Q8将此传感器配置为Raspberry PI 3,并将其连接到GPIO5以根据何时在传感器的范围内输入高将读取值。 超出范围时,传感器将变低。 但我不知道如何编写代码以根据Q4XTBLAF300-Q8此传感器状态从GPIO5引脚读取值。
那么,能否请您告诉我如何从Raspberry PI 3的GPIO5引脚读取值?
using Windows.Devices.Gpio;
public void GPIO()
{
// Get the default GPIO controller on the system
GpioController gpio = GpioController.GetDefault();
if (gpio == null)
return; // GPIO not available on this system
// Open GPIO 5
using (GpioPin pin = gpio.OpenPin(5))
{
// Latch HIGH value first. This ensures a default value when the pin is set as output
pin.Write(GpioPinValue.High);
// Set the IO direction as output
pin.SetDriveMode(GpioPinDriveMode.Output);
} // Close pin - will revert to its power-on state
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.