Hi everyone, I really need your help. I can observed that my Lcd is working normally when I used Hello world code generated by arduino itself. But after I type my code in It become only viewable for 1 line while the second line I can't seem to see or write anything. I'm not sure what is wrong.... Hope someone can guide me to fix this problem.
I'm using Arduino UNO, LCD and Electrical conductivity circuit embedded system from atlas scientific.
Here's my code:
#include <stdlib.h>
#include <string.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#define rxpin 2
#define txpin 3
SoftwareSerial myserial(rxpin,txpin);
LiquidCrystal lcd(12,11,7,6,5,4);
String inputstring ="";
String sensorstring ="";
boolean input_stringcomplete = false;
boolean sensor_stringcomplete = false;
byte arduino_only=0; // 0: computer send code 1 : manual send code
byte i;
char *tds;
char EC[50];
unsigned int s;
int tds_int;
void setup(){
Serial.begin(38400);
myserial.begin(38400);
inputstring.reserve(5);
sensorstring.reserve(30);
lcd.begin(0,0);
lcd.print("TDS:");
}
void serialEvent(){
char inchar = (char)Serial.read();
inputstring += inchar;
if (inchar =='\r')
{input_stringcomplete = true;}
}
void loop(){
if(input_stringcomplete){
myserial.print(inputstring);
inputstring ="";
input_stringcomplete = false;
}
while (myserial.available()){
char inchar = (char)myserial.read();
sensorstring +=inchar;
if(inchar == '\r')
{sensor_stringcomplete = true;}
}
if(sensor_stringcomplete){
Serial.print(sensorstring);
lcd.print(sensorstring);
sensorstring.toCharArray(EC , s);
Serial.print("TDS:");
Serial.println(tds);
lcd.setCursor(0,1);
lcd.print(EC);
sensorstring="";
sensor_stringcomplete = false;
}
}
At my lcd , it only show the first line : TDS:2?
then the rest is empty plus I can also see a weird japanese letter after my data.