Hi and tnx for the answer.
I have two versions of my code. To bring my detector to sending data I need a command sending to it. The only way by now is to do this in loop. I have a second version to try if it works where the command for the detector is outside the loop. Because of some mistakes I had to order a new fio.
First version of my code which is working:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
boolean executed=false;
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
// ------- Quick 3 blinks of backlight -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(150);
lcd.noBacklight();
delay(150);
}
lcd.backlight(); // finish with backlight on
//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0
lcd.setCursor(0,0); //Start at character 4 on line 0
lcd.print("SSM1 Display");
delay(500);
lcd.setCursor(0,1);
lcd.print("by OS");
delay(1500);
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.clear();
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Verbinde SSM1"); delay(500);
lcd.setCursor(0,1);
lcd.print("...programmiere:");
lcd.setCursor(15,1); lcd.blink(); delay(500);
} /*--(end setup )---*/
void loop()
{
if (executed==false){ //Connection to the detector
executed=true;
// sende am seriellen port " " für programmmodus
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print("1"); delay(50); // actual CPS
Serial.print("H"); delay(50); // Standart Format im Programmmodus
Serial.print("l"); delay(300); // licht an und aus
Serial.print("l"); delay(100);
Serial.print("l"); delay(300);
Serial.print("l"); delay(50);
Serial.print("a"); delay(100); // Programmierung abgeschlossen - beginne mit Daten senden
lcd.clear();
lcd.setCursor(0,0); //Display info
lcd.print("...abgeschlossen"); delay(1000);
lcd.setCursor(0,1);
lcd.print("sende..."); delay(3000); lcd.noBlink();
}
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}
Second version - test if works pending:
// --------- TEST -----------------
#include <Wire.h> // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
/*-----( Declare Variables )-----*/
int ssmdat = Serial.read();
void setup()
{
Serial.begin(9600);
while (!Serial) { // Waiting for data via RS232
;
}
lcd.begin(16,2);
// ------- Quick 3 blinks of backlight -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(150);
lcd.noBacklight();
delay(150);
}
lcd.backlight(); // finish with backlight on
//-------- Programming ASMG90 ------------------
lcd.setCursor(0,0); //Start at character 4 on line 0
lcd.print("SSM1 Display");
delay(500);
lcd.setCursor(0,1);
lcd.print("by OS");
delay(1500);
lcd.clear();
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Verbinde SSM1"); delay(500);
lcd.setCursor(0,1);
lcd.print("...programmiere:");
lcd.setCursor(15,1); lcd.blink(); delay(500);
// --------------------- sende am seriellen port " " für programmmodus -----------------
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print(" "); delay(50); Serial.print(" "); delay(50);
Serial.print("1"); delay(50); // actual CPS
Serial.print("H"); delay(50); // Standart Format im Programmmodus
Serial.print("l"); delay(300); // licht an und aus
Serial.print("l"); delay(100);
Serial.print("l"); delay(300);
Serial.print("l"); delay(50);
Serial.print("a"); delay(100); // Programmierung abgeschlossen - beginne mit Daten senden
lcd.clear();
lcd.setCursor(0,0); //Display info
lcd.print("...abgeschlossen"); delay(1000);
lcd.setCursor(0,1);
lcd.print("sende..."); delay(3000); lcd.noBlink();
} /*--(end setup )---*/
void loop()
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(ssmdat);
}
}
}
The part sending to the detector with many spaces and delays is mandatory. I don´t care where in the code but I think when it is outside the loop it will be easier to parse.
On nice additional feature would be the first row which are the seconds to convert in hours/ minutes/ seconds. To see a sort of connection time.
Hope you can help, best regards
Oskar