序言

VSCode 安裝Remote-SSH 配备好树莓派 

VSCode 内置SSH控制面板

 

 

 

终端设备键入指令

 

免费下载&安裝 net5

免费下载
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

 

 

安裝结束后 建立demo

mkdir demo&cd demo
dotnet new console -o demodev

  

ps bash: dotnet: command not found
假如出错依据微软公司docs文档,导进系统变量

 

export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

  

 

 

 

 

 先惯例 hello world!~

iot

 

加上iot库 操纵脚位 这库应用BCM编号17号 下列全部编号全是以BCM部位

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 restore

 

 

 

 

 

 

汇总

Win10 写代码 liunx立即 运作..这.....这也爽死了吧???   希望VS也上这一作用 太必须 了..

 

评论(0条)

刀客源码 游客评论