Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.64 KB

README.md

File metadata and controls

57 lines (39 loc) · 1.64 KB

GpioChip.Net

Remotely

Thanks to SSH this is fastest way to try GPIO without make a line of code or bash inside CHIP itself:

       using (var gpio = new Gpio(new SshGpioInterface("192.168.0.109")))
        {
            Console.WriteLine("Connected");
            for (short i = 0; i < 8; i++)
            {
                var pin = gpio.NewOutputPin(i);
                pin.On();
                pin.Off();
            }
        }

Be sure to put your CHIP's IP instead of "192.168.0.109" and this snippet is running in the same network than CHIP.
This version can run also inside CHIP by using mono like: mono ConsoleTest.exe

Locally

This snipped can run inside CHIP without use SSH which makes it run faster than the remote version although is using sysfs interface. Just change less than one line of code.

       using (var gpio = new Gpio(new ShellGpioInterface()))
        {
            Console.WriteLine("Connected");
            for (short i = 0; i < 8; i++)
            {
                var pin = gpio.NewOutputPin(i);
                pin.On();
                pin.Off();
            }
        }

GPIO Input, Interruptions?

	  var pin = gpio.NewInputPin(0);
	  pin.OnValueChanged += x => Console.WriteLine($"Pin 0: Changed to " + x);
	  Console.ReadKey();

Expanding GPIO

Use the extra pins if you are not using the LCD

	    var lcd4Pin = gpio.NewOutputPin(2, PinBase.LCD_D2);
	    lcd4Pin.On();
	    lcd4Pin.Off();

Need help installing MONO on CHIP?**

apt-get install aptitude
aptitude install mono-complete