Raspberry Pi Shared Library for GPIO

UPDATE: you'll probably need to recompile the library from source, read here for instructions.

So, here is the Raspberry Pi GPIO shared library that I have been working on. When you look at the code, you'll see that I can't really take the credit, the bulk of the code is the same as shown here on the Raspberry Pi wiki. What I have done is fiddle with some compiler options and done some minor tinkering in the code to suit my purposes and style. And it seems to work OK, I'm mainly using it from Mono. It's not the only way to get GPIO access using Mono (another approach is demonstrated here for example), but it's the approach that I've chosen. It means that I can carry on tinkering with the C library without recompiling my Mono code. You could also build versions of the same library for other hardware and then run the same Mono code on different machines. I've made a stub version of the library which allows me to test Mono code on the vitual machine I've set up to run Debian.

The source code for the library is in this zip file. You can recompile from source on the Raspberry Pi (instructions are in the C code) or you can just copy the libpigpio.so file to your /lib folder. You can't hold me responsible if you blow up your own Raspberry Pi though! I have not yet tested the code that gets values from the GPIO, I've only tested the setting of pins at this point. You have been warned.

Of course, you don't have to use this library in Mono, you can use it in C programs too (as well as any other language that supports calling shared libraries). But I've only tested calling it from C and Mono.

Anyway, I hope that it's useful to somebody ... or maybe just interesting. At some point I'll post an example C#/Mono program that uses the library. Have fun!

Comments are closed