Dear Arduino community
I am trying to make something but I’m not really sure how to solve this, I tried to google it but I can’t really find what I need.
I want to log temperature every 2 hours lets say, I can use a delay of two hours but that will make my sketch stop for 2 hours before checking the gas every 10 minutes.
I am wondering what kind of function I have to use, currently I am using the follwing:
(Code to read temperature sensors) delay(2hours) --> (I know it must be 2 hours in MS) (Code to read temperature sensors delay(10 minutes)
I basicly want to create 2 loops not affecting each other with those delays.
I have a setup which checks light sensitivity to conclude if a door is open or shut. Open means the analog signal of the LDR is below 900 and closed means it’s above 900. When I serialprint the data it keeps printing ‘door closed’ because I am using a regular delay and it keeps concluding that it’s closed. I want to only print something when the LDR condition is changed. Let’s say when the door is closed and stays closed for 10 minutes I don’t care and don’t want to see anything on my serialmonitor. When the door opens I want to see appear ‘Door opened’ and that’s it. When the door stays open I don’t want to see any messages.
A MQ-2 gas sensor has as analog output a bunch of numbers (doh) but how can I know what these numbers mean like % of gas in the air,… ?
I’m new to arduino so these problems are probably peanuts to most of you.
Thank you for your help!