Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 1.21 KB

README.md

File metadata and controls

56 lines (38 loc) · 1.21 KB

.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:

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

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

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

Write/Read from GPIOs

To write a signal to a port:

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

To read a signal on a port:

Gpio.GetPortState(Port.PORT27);  

Example

Gpio.SetUpPort(Port.PORT10, Directon.OUT);

while(true)
{
    Gpio.SetPortState(Port.PORT10, State.HIGH);
    Thread.Sleep(250);
    Gpio.SetPortState(Port.PORT10, State.LOW);
    Thread.Sleep(250);
}