From a137ce67f896fa546c93f8bb73c594fecac268aa Mon Sep 17 00:00:00 2001 From: atef Date: Fri, 10 Apr 2026 15:17:46 +0200 Subject: [PATCH] Main program IO project created --- csharp/App/GpioTestingProject/Program.cs | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 csharp/App/GpioTestingProject/Program.cs 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