You are on page 1of 2

Public Class Form1

Dim hasil As String

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


SerialPort1.PortName = "COM7"
SerialPort1.BaudRate = 9600
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.Open()
Timer1.Enabled = True
gr_buka.Visible = False
TextBox1.Visible = False
Label1.Visible = False

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


SerialPort1.WriteLine("H")
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


SerialPort1.WriteLine("L")
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick


TextBox1.Text = " "
hasil = SerialPort1.ReadExisting()

If Len(hasil) > 0 Then


TextBox1.Text = hasil

If Mid(hasil, 1, 11) = "Garasi Buka" Then


TextBox1.Visible = True
gr_buka.Visible = True
gr_tutup.Visible = False
Label1.Visible = Not Label1.Visible

ElseIf Mid(hasil, 1, 12) = "Garasi Tutup" Then


TextBox1.Visible = False
gr_buka.Visible = False
gr_tutup.Visible = True
Label1.Visible = False

End If
End If
End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles


TextBox1.TextChanged

End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs)

End Sub
End Class

You might also like