I trying to send a string to a Quasar relay kit #3108v3 using the code below. The com port is opening ok yet I can trigger a relay? Help its so easy in qbasic a simple print command.
Imports System
Imports System.IO.Ports
Namespace Shauntrapmatic.test
Public Class shauntest
Public Shared Sub Main()
Console.WriteLine("Available Ports on this computer:")
For Each portname As String In SerialPort.GetPortNames
Console.WriteLine("PORT: " & portname)
Next
Console.WriteLine()
Dim testport As String = SerialPort.GetPortNames(0)
Using port As New SerialPort(testport)
port.BaudRate = 9600
port.DataBits = 8
port.Parity = Parity.None
port.StopBits = StopBits.One
'Write a string
port.Open()
port.WriteLine("N1")
port.Close()
Console.WriteLine("Wrote to the {0} port ", testport)
End Using
Console.WriteLine(Environment.NewLine)
Console.WriteLine("Main method complete. Press Enter ")
Console.ReadLine()
End Sub
End Class
End Namespace
N1 being the relay's command to turn on relay 1
What am I doing wrong?????
!--removed tag-->
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).