https://github.com/dotnet/iot
How to call
using System.Device.Gpio;
Since Git has an L Chika sample source written in C #, I will use it.
Click on the Linux Arm
After clicking, you can copy and paste the path on the screen, so get the path
$wget path
$ mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.100-linux-x64.tar.gz -C $HOME/dotnet
$ vim ~/.bashrc
#Add path
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet
pass dotnet through the path
using System;
using System.Device.Gpio;
using System.Threading;
namespace led {
class Program {
static void Main(string[] args) {
//Specify the GPIO number
int pin = 7;
GpioController controller = new GpioController();
controller.OpenPin(pin, PinMode.Output);
int lightTimeInMilliseconds = 1000;
int dimTimeInMilliseconds = 200;
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);
}
}
}
}
It can be executed by specifying the dll. There is also a way to output to exe.
$ dotnet led.dll
controller.OpenPin (pin, PinMode.Output) should number GPIO
[Search for remote GPIO](https://www.amazon.co.jp/Visual-Studio-%E3%81%A7Raspberry-Pi-%E3%83%AA%E3%83%A2%E3%83%BC % E3% 83% 88GPIO% E5% B0% 8E% E5% 85% A5% E7% B7% A8-ebook / dp / B07HNQ9C6X /)
Set the SDK path to MoNoDevelop
Recommended Posts