I recently purchased the USB + serial backpack kit with the 16x2 LCD. It has been a fun little kit so far, but I want to start writing some code to control it a little better.
Using Visual Basic 2013, I can successfully send it ASCII characters, but it will not recognize the 0xFE command. instead the LCD displays a questionmark when the 0xFE is received. If I send it other hex characters, they are displayed in the appropriate ASCII format.
In this case I am sending 0xFE 0x58 to clear the screen of any text.
I am sending the commands as Chr(254) & Chr(88)
The LCD displays ?X
Here is some code that I am using to see if I can clear the screen:
Code: Select all
Imports System
Imports System.IO.Ports
Private Sub CommPortSetup()
Me.AcceptButton = Button1
With mySerialPort
.PortName = "COM19"
.BaudRate = 34800
.DataBits = 8
.Parity = Parity.None
.StopBits = StopBits.One
.Handshake = Handshake.None
End With
Try
mySerialPort.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
CommPortSetup()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
mySerialPort.WriteLine(Chr(254) & Chr(88)) 'Try to clear the screen
End Sub
End Class