私の現在のコードでは、一度に1文字が読み取られるため、2つの別々の行のシリアル読み取りが1つの大きな入力として読み取られます。これにより、ArduinoのLCDディスプレイの同じ行に両方の行が書き込まれます。これらの入力を別の行に書き込むためにヌル文字またはブレークラインを設定する方法はありますか?
編集:申し訳ありませんが、入力テキストが可変長になるように指定する必要がありました。
これが私のArduinoコードです:
#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;
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);
}
}