首页 > Web开发 > 详细

Raspberry pi 3b+ 安装dotnet5 VSCode Remote-SSH 远程开发

时间:2021-07-24 11:49:40      阅读:37      评论:0      收藏:0      [点我收藏+]

前言

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也上这个功能 太需要了..

 

Raspberry pi 3b+ 安装dotnet5 VSCode Remote-SSH 远程开发

原文:https://www.cnblogs.com/leoxjy/p/15054193.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!