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:
#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();
delay(10);
Serial.print(line1);
lcd.print(line1);
}
}
Here is the relevant part of the VB code:
Public Delegate Sub MessageDelegate(ByVal Data As String)
Private Sub Apply_Click_Serial(sender As System.Object, e As System.EventArgs) Handles Apply.Click
SerialPort1.WriteLine(Output1Text.Text)
SerialPort1.Write(Output2Text.Text)
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"
SerialPort1.Open()
End If
End Sub