July 3, 2012

Raspberry Pi GPIO in .net

I setout to create a simple library for raspberry pi gpio using the slow but easy to work with file system gpio.  This is useful for low speed io such as controling relays and such.  If you can live with a couple hundred ms latency this is a useful class for that.  I am currently using it to control a set of lawn sprinklers and low voltage lighting.

There are two real interfaces for the class the direction and value.  You set the direction to input or output.  In input mode you cannot set a value to the pin.  In both modes the current value of the pin can be read.  The pins can be modified externaly and no assumptions are made as to the current state of the pin.  This adds latency to setting the pin value but I didn’t want to make any assumptions and have that cause issues down the road.

If you don’t care about the exceptions just trap them it throws a general io exception.

With that in mind using the pins you generally would just set the pins direction when you start your code, then read or write to them as needed using the object properties.


Leave a comment

You must be logged in to post a comment.