Innovenergy_trunk/csharp/App/GpioTestingProject/Program.cs

39 lines
973 B
C#

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}");
}
}
}