Sending commands to USB + Serial Backpack Kit

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dmphotog
 
Posts: 6
Joined: Wed Oct 05, 2011 11:52 am

Sending commands to USB + Serial Backpack Kit

Post by dmphotog »

Hello,

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

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Sending commands to USB + Serial Backpack Kit

Post by adafruit_support_rick »

That should work. It must be something that VB is doing. I don't know.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Sending commands to USB + Serial Backpack Kit

Post by adafruit_support_bill »

I believe the Chr() function is trying to convert it to a printable character. I'm not a VB user, but can you just print the raw byte value?

Code: Select all

mySerialPort.WriteLine(&HFE & Chr(88))

User avatar
dmphotog
 
Posts: 6
Joined: Wed Oct 05, 2011 11:52 am

Re: Sending commands to USB + Serial Backpack Kit

Post by dmphotog »

I will give it a try and let you know how it goes. Thank you!

User avatar
dmphotog
 
Posts: 6
Joined: Wed Oct 05, 2011 11:52 am

Re: Sending commands to USB + Serial Backpack Kit

Post by dmphotog »

When I used (&HFE & Chr(88)) in place of (Chr(254) & Chr(88)), the LCD displayed 254X

Over the weekend I found some examples of code I wanted to try and this one appeared to work!

Code: Select all

mySerialPort.Write(New Byte() {&HFE}, 0, 1)
mySerialPort.Write(Chr(88))
Thanks again for your help.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Sending commands to USB + Serial Backpack Kit

Post by adafruit_support_bill »

Great! Thanks for the follow-up.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”