Main program IO project created
This commit is contained in:
parent
d97167316a
commit
a137ce67f8
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue