Go Down

Topic: Writing to different Arduino LCD line from Visual Basic Input (Read 932 times) previous topic - next topic

Dec 05, 2012, 08:59 pm Last Edit: Dec 05, 2012, 09:00 pm by BruceMacD Reason: 1
 I'm creating a program that takes text from Visual Basic, and writes it on an Arduino's LCD. The only issue is that I need the write the second line to the second line of the LCD, and at the moment both lines come out on the first line of the LCD. Does anyone know how to move the LCD cursor to the second line for the second write?

Here is the Arduino code:
Code: [Select]
#include <LiquidCrystal.h>
#include <string.h>
// These are the pins our LCD uses.
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 // initalize the lcd, and button input at zero.
 int lcd_key     = 0;
 int adc_key_in  = 0;
int read_LCD_buttons()

 void setup()
Serial.begin(9600); //Set the serial monitor.
lcd.begin(16, 2); //Set the LCD
char line1;
void loop()

if (Serial.available() > 0) { //If the serial monitor is open it will read a value.
line1 = Serial.read();

Here is the relevant part of the VB code:
Code: [Select]
Public Delegate Sub MessageDelegate(ByVal Data As String)
   Private Sub Apply_Click_Serial(sender As System.Object, e As System.EventArgs) Handles Apply.Click
   End Sub
   Private Sub connect_Click(sender As System.Object, e As System.EventArgs) Handles connect.Click
       If Not SerialPort1.IsOpen Then
           SerialPort1.PortName = "COM3"
       End If
   End Sub


There is a setCursor() method in the LiquidCrystal library.

Thank you , but how would we use with our current code that prints one character every time it circles in the loop?


Thank you , but how would we use with our current code that prints one character every time it circles in the loop?

You make your code so that it dosn't. One way would be to use an escape sequence. When you see a certain character, one of the non printing ones, then the next few characters call up the set cursor method with those characters setting the position.


Do you think a character array would work better?

I have no idea how it would work at all. Cair to explain?

I'm thinking about finding away to store the characters for line 1 in an array , then a separate character array for line 2. The problem with this is I don't know how to set a character array to variable length in c (as the text to write to the LCD will change).


You still have th same problem of knowing what array you are recieving and sorting a header from the actual data.
As for a C array just send the characters and end it with a null, this will give you a C string.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131