Hello floresta,
thank you very much for your reply! I have not heard before, that the serial monitor could restart the program, in fact this is really happening. This will delay everything, but should not cause any problem.
For data-Acquisition, processing the data and showing it in the serial monitor a shortend example is:
unsigned long counts = 0;
unsigned long AlteCounts = 0;
unsigned long AktuelleCounts = 0;
unsigned long AlteMillis = 0;
unsigned long AktuelleMillis = 0;
void setup() {
Serial.begin(9600);
pinMode(2,INPUT);
digitalWrite(2,HIGH);
pinMode(6,OUTPUT);
delay(10000);
digitalWrite(6,HIGH); //starts second Arduino
}
void loop() {
attachInterrupt(0,tube_impulse,RISING);
if(counts >= AlteCounts && millis() >= AlteMillis){
AktuelleCounts = counts;
AktuelleMillis = millis();
Serial.print(AktuelleCounts);
Serial.print(" Counts, ");
Serial.print(AktuelleMillis);
Serial.println(" Zeit");
AlteCounts = counts;
AlteMillis = millis();
};
}
void tube_impulse() {
counts++;
}
I'm using the display with the following code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void setup() {
lcd.begin(16, 2);
lcd.print(" Herzlich");
lcd.setCursor(0,1);
lcd.print(" Willkommen");
delay(2000);
lcd.setCursor(0,1);
lcd.print(" ");
lcd.home();
lcd.print("hello, world! #");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
}
And my combination would be the following code:
unsigned long counts = 0;
unsigned long AlteCounts = 0;
unsigned long AktuelleCounts = 0;
unsigned long AlteMillis = 0;
unsigned long AktuelleMillis = 0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void setup() {
Serial.begin(9600);
pinMode(2,INPUT);
digitalWrite(2,HIGH);
lcd.begin(16, 2);// This part (4 lines) is still working!!
lcd.print(" Herzlich");
lcd.setCursor(0,1);
lcd.print(" Willkommen");
pinMode(6,OUTPUT);
delay(10000);
digitalWrite(6,HIGH); //starts second Arduino
lcd.clear(); //Clearing the display is working too
}
void loop() {
attachInterrupt(0,tube_impulse,RISING);
if(counts >= AlteCounts && millis() >= AlteMillis){
AktuelleCounts = counts;
AktuelleMillis = millis();
//from now on nothing is working any more :(
lcd.print(AktuelleCounts);
lcd.print(" Aktuelle Counts");
Serial.print(AktuelleCounts);
Serial.print(" Counts, ");
Serial.print(AktuelleMillis);
Serial.println(" Zeit");
AlteCounts = counts;
AlteMillis = millis();
};
}
void tube_impulse() {
counts++;
}
I have shortend these codes and hope, that someone can see my error. Thank you very much!