diff --git a/csharp/App/GpioTestingProject/Program.cs b/csharp/App/GpioTestingProject/Program.cs new file mode 100644 index 000000000..aba8600a8 --- /dev/null +++ b/csharp/App/GpioTestingProject/Program.cs @@ -0,0 +1,39 @@ +using System; +using System.Threading; +using GPIORaspberryPI4; + +namespace InnovEnergy.App.GpioTestingProject; + +static class Program +{ + static void Main(string[] args) + { + Console.WriteLine("GPIO17 Relay Test Starting..."); + + using IRelayOutput relay = new RelayOutput(pin: 27, activeLow: false); + using IDigitalInput input = new DigitalInput(pin: 17, pullUp: true, activeLow: true); + + try + { + while (true) + { + if (input.Read()) + { + relay.On(); + Console.Write("\rInput ACTIVE -> Relay ON "); + } + else + { + relay.Off(); + Console.Write("\rInput INACTIVE -> Relay OFF "); + } + + Thread.Sleep(100); + } + } + catch (Exception ex) + { + Console.WriteLine($"ERROR: {ex.Message}"); + } + } +} \ No newline at end of file