I have a MKR 1010 and want to run tqo diffrent functions in it. Rhe main problem is that i do not want to get too much delays from both the codes. So i need to figure out a way to run two codes in parallel. Help me in this
Bad news, the processors each have only one core therefore each can only execute only one instruction at a time. It does this very rapidly but not two or more concurrently. You will have to write your code code runs on a seperate core. If you want you can write your code in such a way that it will do both tasks without much delay but you cannot use the delay instruction or any blocking code.
If you want more help consider posting your code following forum guidelines and a annotated schematic if there is hardware connected as well as links to technical information on the hardware.
See Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE
I just want to control motors while using DHT 11 to swnd me temperature and humidity. This requires a 2 sec delay which i cannot take for controlling motors
Do not use delay(), use a millis() timer instead.
See:
Hello Akash.K
We need some additional information.
Post your sketch, well formated, with well-tempered comments and in so called code tags "< code >" and a detailed circuit diagram to see how we can help.
Have a nice day and enjoy coding in C++.
I just dont understand how millis() timer work. i just need a simple explanation on what each code do so that i could implement it correctly
millis() simply returns the number of milliseconds that have passed since the Arduino was last started or reset. So, if you record its value now then compare it with the value returned later you can determine how much time has passed between the two readings
Look at the topics that I linked to above
ok ill figure it out. Thank you
In my opinion this classic blink without delay example makes it unnescessary hard to understand the basic concept for the following reasons:
-
the most important reason is that the "classic" blink-without-delay code does not emphasize on the difference delay() is a simple function-call and BWD requires multiple lines of code and works completely different.
As long as newcomers try to see a delay()-thing in the code they must fail. -
The classic BWD-example uses three variables
-
the variable-names are not really intuitive and self-explaining
-
variables that are used must be placed in different lines of code
I claim that this tutorial is easy to understand for three reasons:
- it uses an everyday example that is easy to imagine that explains the basic concept
- easy to calculate example-numbers are used
- has example-codes that are well commented.
And also this might be of interest
best regards Stefan
Thanks, I will check it out.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.