项目作者: tim-koehler

项目描述 :
Small Library to simplify the work with GPIOs on the Raspberry Pi in your .NetCore application
高级语言: C#
项目地址: git://github.com/tim-koehler/NetCoreGpioLibrary.git
创建时间: 2018-06-20T19:29:32Z
项目社区:https://github.com/tim-koehler/NetCoreGpioLibrary

开源协议:

下载


.NetCoreGpioLibrary for Raspberry Pi

This is a small Library to simplify the work with GPIOs on the Raspberry Pi in your .NetCore application.

Prerequisites

You should already have a working .NetCore environment on your Raspberry set up.

Installation

  1. Download the dll file
  2. Add the library to your existing Project

Use the library

Setup GPIO ports

Before using a GPIO port you have to configure it:

  1. Gpio.SetUpPort(Port.PORT10, Direction.OUT); // Write to port
  2. Gpio.SetUpPort(Port.PORD27, Direction.IN); // Read from port

If your input signal is inverted you can simply invert that:

  1. Gpio.SetUpPort(Port.PORD27, Direction.IN, true); // Read from inverted port

Write/Read from GPIOs

To write a signal to a port:

  1. Gpio.SetPortState(Port.PORT10, State.HIGH);

To read a signal on a port:

  1. Gpio.GetPortState(Port.PORT27);

Example

  1. Gpio.SetUpPort(Port.PORT10, Directon.OUT);
  2. while(true)
  3. {
  4. Gpio.SetPortState(Port.PORT10, State.HIGH);
  5. Thread.Sleep(250);
  6. Gpio.SetPortState(Port.PORT10, State.LOW);
  7. Thread.Sleep(250);
  8. }