C#开发ESP32E(1)IO配置操作
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);
}
}
参考API文档
https://docs.nanoframework.net/api/System.Device.Gpio.html