Skip to content

Latest commit

 

History

History
66 lines (39 loc) · 2.34 KB

README.md

File metadata and controls

66 lines (39 loc) · 2.34 KB

RaspberryGPIOManager   raspberrypi.org

This simple C# library allows you to easily manage any GPIO pin on your Raspberry Pi. If you wish to learn more about GPIO, you may want to look at this. To see an example on how the library works, see below.


Notice: I'm currently performing major changes to the code and the repository. Sorry if I'll mess up and break some source files.

Compiling

If you're keeping your RPi setup as lightweight as possible and you're not using an IDE you can compile this library and your project as follows:

mcs -t:library GpioPin.cs Exceptions.cs -out:Raspberry-GPIO-Manager.dll

mcs -reference:"path/to/previous/generated.dll" yourProject.cs

GPIOPinDriver object

The GPIOPinDriver object is the one you need to build in order to perform any action. In its constructor you have to specify the GPIO pin to associate, and you may also want to give the direction and the initial value to assign.

var pin1 = new GPIOPinDriver(GPIOPinDriver.Pin.GPIO23);

var pin2 = new GPIOPinDriver(GPIOPinDriver.Pin.GPIO23, GPIOPinDriver.GPIODirection.Out, GPIOPinDriver.GPIOState.Low);

GPIOPinDriver properties

Once you have created your object(s), you can access following properties:

Direction - In or Out, (treat it as an input or output pin)

GPIOPin - [Readonly] The pin that is being controlled.

State - The current value of the signal. In output mode this property can be used to switch on or off the pin, in input mode to read the value of it (High/Low).

Coming Soon

  • Possibility to handle events on GPIO pin state changes
  • Object to handle serial communication

Notes

GPIOPinDriver class implements IDisposable interface, that is to say it should be disposed at the end, calling either Dispose() or Unexport() function.

IMPORTANT: Accessing GPIO pins require root permissions!


Raspberry Pi is a trademark of the Raspberry Pi Foundation.