L Chika on Raspberry Pi C #

Use Microsoft GPIO library

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.

Sample Source

Install NetCore 3.1 on Raspberry Pi

Click on the Linux Arm スクリーンショット 2020-06-01 17.27.58.png

.net core sdk DownLoadPage

After clicking, you can copy and paste the path on the screen, so get the path スクリーンショット 2020-06-01 17.13.58.png

$wget path

Install .NET Core SDK

$ 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

Developing console apps on VisualStudioMac

スクリーンショット 2020-06-01 17.02.26.png Select .net Core スクリーンショット 2020-06-01 17.02.35.png ## Get System.Device.Gpio from Nuget Download the MicroSoft Gpio library スクリーンショット 2020-06-01 17.01.24.png
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);
            }
           }
      }
}

Build

It can be executed by specifying the dll. There is also a way to output to exe.

$ dotnet led.dll

point

controller.OpenPin (pin, PinMode.Output) should number GPIO スクリーンショット 2020-06-01 17.05.29.png

Task

[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 /)

Open the project file created in VisualStudioMac in MonoDevelop and debug it.

Set the SDK path to MoNoDevelop スクリーンショット 2020-06-01 17.04.46.png

I was able to confirm the operation of L Chika in C #.

L Chika in Python

Recommended Posts

L Chika on Raspberry Pi C #
Try L Chika with raspberry pi
Installation of Docker on Raspberry Pi and L Chika
pigpio on Raspberry pi
Cython on Raspberry Pi
Introduced pyenv on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
Testing uart communication on Raspberry Pi
MQTT on Raspberry Pi and Mac
raspberry pi 4 centos7 install on docker
Install ghoto2 on Raspberry Pi (memo)
Try using ArUco on Raspberry Pi
OpenCV installation procedure on Raspberry Pi
Power on / off Raspberry pi on Arduino
Install OpenMedia Vault 5 on Raspberry Pi 4
Build wxPython on Ubuntu 20.04 on raspberry pi 4
"Honwaka Notification Lamp" on Raspberry Pi Part 2
Detect "brightness" using python on Raspberry Pi 3!
USB boot on Raspberry Pi 4 Model B
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Enable UART + serial communication on Raspberry Pi
Adafruit Python BluefruitLE works on Raspberry Pi.
Accelerate Deep Learning on Raspberry Pi 4 CPU
Set swap space on Ubuntu on Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Use the Grove sensor on the Raspberry Pi
Install 64-bit OS (bate) on Raspberry Pi
Install docker-compose on 64-bit Raspberry Pi OS
Run servomotor on Raspberry Pi 3 using python
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Working with sensors on Mathematica on Raspberry Pi
Mount Windows shared folder on Raspberry Pi
Matrix multiplication on Raspberry Pi GPU (Part 2)
How to install NumPy on Raspberry Pi
RaspberryPi L Chika with Python and C #
[C, C ++, Python, JavaScript] L Chika with Edison
Working with GPS on Raspberry Pi 3 Python
Raspberry Pi backup
Detect slide switches using python on Raspberry Pi 3!
Build a Django environment on Raspberry Pi (MySQL)
Try using a QR code on a Raspberry Pi
Enjoy electronic work with GPIO on Raspberry Pi
Power on / off your PC with raspberry pi
Use Grove-Temperature & Humidity Sensor (DHT11) on Raspberry Pi
Make DHT11 available on Raspberry Pi + python (memo)
Beginning cross-compilation for Raspberry Pi Zero on Ubuntu
Sound the buzzer using python on Raspberry Pi 3!
Play with your Ubuntu desktop on your Raspberry Pi 4
Display CPU temperature every 5 seconds on Raspberry Pi 4
Introduced Ceph on Kubernetes on Raspberry Pi 4B (ARM64)
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Build an Arch Linux environment on Raspberry Pi
Record temperature and humidity with systemd on Raspberry Pi
Build an OpenCV4 environment on Raspberry Pi using Poetry
GPGPU with Raspberry Pi
Try debugging Python on Raspberry Pi with Visual Studio.
Try using the temperature sensor (LM75B) on the Raspberry Pi.
Raspberry Pi video camera
Control brushless motors with GPIOs on Raspberry Pi Zero