#include <LiquidCrystal.h> ///คำสั่ง #include แล้วตามด้วยไฟล์ที่อยู่ใน Folder ชื่อ Libraries
#include <Wire.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
String inputstring = ""; //a string to hold incoming data from the PC
String sensorstring = ""; //a string to hold the data from the Atlas Scientific product
boolean input_stringcomplete = false; //have we received all the data from the PC
boolean sensor_stringcomplete = false; //have we received all the data from the Atlas Scientific
//product
///////////////////////////////////////////////////
void setup(){
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0); //set up the hardware
Serial.begin(38400); //set baud rate for the hardware serial port_0 to 38400
Serial1.begin(38400); //set baud rate for software serial port_3 to 38400
inputstring.reserve(5); //set aside some bytes for receiving data from the PC
sensorstring.reserve(30); //set aside some bytes for receiving data from Atlas Scientific
} //product
/////////////////////////////////////////////////
void serialEvent() { //if the hardware serial port_0 receives
char inchar = (char)Serial.read(); //a char
inputstring += inchar; //get the char we just received
if(inchar == '\r') {input_stringcomplete = true;} //add it to the inputString
} //if the incoming character is a <CR>,
//set the flag
/////////////////////////////////////////////////
void serialEvent1( ){ //if the hardware serial port_3 receives
char inchar = (char)Serial1.read(); //a char
sensorstring += inchar; //get the char we just received
if(inchar == '\r') {sensor_stringcomplete = true;} //add it to the inputString
} //if the incoming character is a <CR>,
//set the flag
//////////////////////////////////////////////
void loop(){ //here we go...
if (input_stringcomplete){ //if a string from the PC has been received in its entierty
Serial1.print(inputstring);
inputstring = ""; //clear the string:
input_stringcomplete = false; //reset the flag used to tell if we have received a completed
} //string from the PC
if (sensor_stringcomplete){ //if a string from the Atlas Scientific product has been
Serial.println(sensorstring);
lcd.clear();
lcd.print(sensorstring); <<<<< เนี่ยอ้ะครับ[b][/b]
sensorstring = ""; //send that string to to the PC's serial monitor
sensor_stringcomplete = false; //clear the string:
} //reset the flag used to tell if we have received a
} //completed string from the Atlas Scientific product