I'm trying to make a function that when called, waits for a trigger signal to change from 0 to 1 on a digital input, then delays 5 seconds, takes an ADC and displays the result to the LCD. Right now, it waits for the trigger singnal, but then once the trigger level goes from 0 to 1, the LCD very quickly flashes 'Taking Reading...' and then it seems that it crashes because the LCD is cleared and I can't get anything else to happen. Here is the code I have for the function so far:
void doReading(){
noInterrupts();
lcd.clear();
lcd.print("Waiting...");
//int triggered = 0;
while(trigger){
trigger = digitalRead(triggerPin);
delay(100);
}
//probably have to add a delay
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Taking Reading..");
delay(5000);
curReading = analogRead(sensorPin);
lcd.clear();
getDateDs1307();
lcd.setCursor(0,0);
lcd.print("Reading: ");
lcd.print(curReading);
delay(2000);
//writeToEeprom();
exitFunct = 1;
interrupts();
while(exitFunct);
}