Hello, I'm trying to a code where every time it detects liquid, it can tell me the time. I'm a little lost after trying out different time functions such as millis(). I'm a complete beginner to the Arduino, thank you for your time!
/*
Made on Jan 12, 2020
By MehranMaleki @ Electropeak
Home
*/
#define Liquid_Detection_Pin 2 //Output pin on sensor
void setup() {
Serial.begin(9600);
pinMode(Liquid_Detection_Pin, INPUT);
}
void loop() {
if (digitalRead(Liquid_Detection_Pin)) {
Serial.println("Liquid Detected!");
}
else {
Serial.println("No Liquid!");
}
delay(1000);
}
Do you want to know the actual time of the event, in which case you will need a source for the time such as a Real Time Clock (RTC), or the time relative to some previous event, in which case you could use millis() or an RTC
Which Arduino board do you have ?
If it is WiFi enabled then you could consider getting the time from the Internet
I'm using the Arduino Uno which I believe it cannot connect to the internet? How would I add millis()? Would I just add mytime=millis() under Serial.println("Liquid Detected!")?
if (digitalRead(Liquid_Detection_Pin)) {
Serial.println("Liquid Detected!");
mytime=millis();