VSCode 安装Remote-SSH 配置好树莓派 linux
VSCode 自带SSH控制台bash
终端输入命令编码
下载
wget https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.205/dotnet-sdk-5.0.205-linux-arm.tar.gz 安装 mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-5.0.205-linux-arm.tar.gz -C $HOME/dotnet
安装完毕后 建立demospa
mkdir demo&cd demo dotnet new console -o demodev
ps bash: dotnet: command not found
若是报错根据微软docs文档,导入环境变量.net
export DOTNET_ROOT=$HOME/dotnet export PATH=$PATH:$HOME/dotnet
先国际惯例 hello world!~rest
添加iot库 控制引脚 这库使用BCM编码17号 如下全部序号都是以BCM位置code
dotnet add package System.Device.Gpio
using System; using System.Device.Gpio; using System.Threading; namespace demodev { class Program { static void Main(string[] args) { Console.WriteLine("Hello World! runtime pi"); var pin = 17; var lightTimeInMilliseconds = 500; var dimTimeInMilliseconds = 200; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"Let's blink an LED!"); using (GpioController controller = new GpioController()) { controller.OpenPin(pin, PinMode.Output); Console.WriteLine($"GPIO pin enabled for use: {pin}"); Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs eventArgs) => { controller.Dispose(); }; while (true) { Console.WriteLine($"Light for {lightTimeInMilliseconds}ms"); controller.Write(pin, PinValue.High); Thread.Sleep(lightTimeInMilliseconds); Console.WriteLine($"Dim for {dimTimeInMilliseconds}ms"); controller.Write(pin, PinValue.Low); Thread.Sleep(dimTimeInMilliseconds); } } } } }
dotnet run
ps:若是编译不过同 得先 dotnet restoreblog
win10 敲代码 liunx直接 运行..这.....这也太爽了吧??? 期待VS也上这个功能 太须要了..文档