1.Nuget安装nanoFramework.System.Device.Gpio
2.创建GpioController和GpioPin对象
点击查看代码
var gpio=new GpioController();
//参数1为引脚号(查看电路图)(此处对应为D2灯)
//参数2为模式(输入,输出,上下拉等)(此处对应为输出)
var led = gpio.OpenPin(2,PinMode.Output);
3.周期闪烁D2
完整代码
点击查看代码
public static void Main()
{
var gpio=new GpioController();
var led = gpio.OpenPin(2,PinMode.Output);
while (true)
{
//反转电平信号
led.Toggle();
Thread.Sleep(1000);
}
}
标签:led,C#,System,ESP32E,IO,GpioController,var,gpio,PinMode From: https://www.cnblogs.com/hngyElectric/p/17409537.html参考API文档
https://docs.nanoframework.net/api/System.Device.Gpio.html