I now I have now business asking here, because I am not a customer
this is a real simple question I would like to run a loop with in a loop or multiple loops. I had the code at one time I moved to a new windows & laptop and formatted the other before thinking about my arduio stuff.
void loop()
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: void loop()
It is certainly possible to create multiple loops and nested loops in the Arduino language. If you can be a little more specific about what you are trying to achieve, we might be able to offer more specific advice.
- X74B623CBW7TB85
- Posts: 10
- Joined: Tue Jun 03, 2014 7:48 pm
Re: void loop()
right now the display updates and one relay is close then the next time the next relay with the next screen update, so I wanted to run a loop with in the loop or multiple loops so I can control the relays how fast they open and close in one and the display in the other. I want to pass the Var to the other loop being the display loop and show what relays are active.
Last edited by X74B623CBW7TB85 on Thu Jun 05, 2014 11:01 pm, edited 1 time in total.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: void loop()
The Arduino is single threaded, so you can't have loops running in parallel. Typically the way it is done for embedded controllers is to have one loop with 3 phases:
1 - Read all the inputs
2 - Update the display and perform any control calculations
3 - Update all the outputs.
1 - Read all the inputs
2 - Update the display and perform any control calculations
3 - Update all the outputs.
- X74B623CBW7TB85
- Posts: 10
- Joined: Tue Jun 03, 2014 7:48 pm
Re: void loop()
You stated before
Ok I have had and used the HC11 scan a 3x4 key pad while reading inputs to get voltage readings and update the screen. then when a key was pressed it could perform one of another 10 functions set up as case statements, while updating the screen at the same time. with the same amount of ram 32k. I still have the code and the compiler / upload tool don't have the cable any more, was not usb, it was serial upload
MC68HC11 Microcontroller PDF the problem I had with that one was it was a one shot burn so you got one chance to get it correct. and most of the time the chips were soldered not socketed.
fact of the matter is the Arduino is more supported with libs and all back then it was had to come up with any more then a simple mfg lib and if you wanted it you had to modify the lib this was 21 years ago. So I don't understand why it is so limited when it appears to do so much.
I have taken up more then enough of unpaid questions here, Thank you for your answer
and you take it back now hereadafruit_support_bill wrote:It is certainly possible to create multiple loops and nested loops in the Arduino language. If you can be a little more specific about what you are trying to achieve, we might be able to offer more specific advice.
I am not attempting to be rude hereadafruit_support_bill wrote:The Arduino is single threaded, so you can't have loops running in parallel. Typically the way it is done for embedded controllers is to have one loop with 3 phases:
1 - Read all the inputs
2 - Update the display and perform any control calculations
3 - Update all the outputs.
Ok I have had and used the HC11 scan a 3x4 key pad while reading inputs to get voltage readings and update the screen. then when a key was pressed it could perform one of another 10 functions set up as case statements, while updating the screen at the same time. with the same amount of ram 32k. I still have the code and the compiler / upload tool don't have the cable any more, was not usb, it was serial upload
MC68HC11 Microcontroller PDF the problem I had with that one was it was a one shot burn so you got one chance to get it correct. and most of the time the chips were soldered not socketed.
fact of the matter is the Arduino is more supported with libs and all back then it was had to come up with any more then a simple mfg lib and if you wanted it you had to modify the lib this was 21 years ago. So I don't understand why it is so limited when it appears to do so much.
I have taken up more then enough of unpaid questions here, Thank you for your answer
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: void loop()
Perhaps if you attached your code we could find a solution for you. What Bill was saying is you can have nested loops but they do one thing at a time and then go on to the next. Not two things at the same time. A micro operating at 16mhz can do quite a bit in very little time.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: void loop()
What I said was: You can have multiple loops:
And you can have nested loops
but you cannot have 2 loops running in parallel. There is no contradiction there.
Code: Select all
for(...)
{
}
for(...)
{
}
Code: Select all
for(...)
{
for(...)
{
}
}
Please be positive and constructive with your questions and comments.