tidstagning/Tidstagning/Relay.cs

30 lines
645 B
C#
Raw Normal View History

2020-08-06 15:31:10 +00:00
using System.IO.Ports;
2020-04-21 15:47:38 +00:00
namespace Tidstagning
{
class Relay
{
SerialPort com;
public Relay(string ComPort)
{
com = new SerialPort();
com.PortName = ComPort;
com.BaudRate = 9600;
com.Open();
}
public void Set(int output, byte state) {
byte[] command = {0xff, 0x01, state};
com.Write(command, 0, 3);
}
public void Close() {
if(com.IsOpen)
com.Close();
}
public static string[] GetPorts()
{
return SerialPort.GetPortNames();
}
}
}