Can someone give me an EXAMPLE CODE how to read data from a soil moisture sensor every 12 hours without using the MILLIS and DELAY function?.
I am using :
int sensorPin = 0; // select the input pin for the Soil moisture sensor
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
delay(1000);
Serial.print("sensor = " );
Serial.println(sensorValue);
}
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags: [code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.
dataoikogarden:
without using the MILLIS
Why don't you want to use millis()?
If you need better timing accuracy then I recommend using an RTC (real time clock).
Thanks for the respont.
I am not so much interstead for a accurasy. I do not want to use miilis because it hastime limit .
If i am using RTC whai for example i need to change inside the code for similliar to delayed without the the time limitation after 49 days or so? That why i am trying to figure days now how to do it.
Ah, an XY problem! There is absolutely no time limit problem for you using millis() as long as you write your code correctly, and that's quite easy to do. You can find an example of how to do this at File > Examples > 02.Digital > BlinkWithoutDelay and the associated tutorial: