Hello,
I'm trying to control a Sparkfun SerLCD using the SerialPort class in vb.net, but I'm having some issues sending control characters to the screen. I can send the 'clear screen command', but not anything else.
The LCD screen clears up when you send special command character '0xFE' followed by '0x01'. In Arduino language:
Thanks for the reply.
I have SerLCD connected to GND,5V and TX pin, as described here:Arduino Playground - SparkFunSerLCD. The Arduino program simply gets the serial data and writes it to the SoftwareSerial as you describe.
My vb .net program sends normal text (ASCII characters) and Arduino sends them correctly to the SerLCD display. That part works! My problem is sending the special characters from the vb program! When I send the com1.Write(ChrW(254) + ChrW(128)) command from vb, instead of the cursor moving to line1 as it should, i get questionmarks like this '??'.
I think it has to do with the vb commands, I tried both Chr() and ChrW() but with no luck..
Thanks for reply!
You pointed me to the right direction, i've found the solution.
In order to send special characters in vb .net to SerLCD you should send them as hex:
Using com1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("COM3")
Dim data() As Byte = {&HFE, &H1} 'clear the screen
com1.Write(data, 0, data.Length)
Dim data2() As Byte = {&HFE, 128} 'move cursor to line 1
com1.Write(data2, 0, data.Length)
com1.Close()