void loop()

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
X74B623CBW7TB85
 
Posts: 10
Joined: Tue Jun 03, 2014 7:48 pm

void loop()

Post by X74B623CBW7TB85 »

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.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: void loop()

Post by adafruit_support_bill »

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.

User avatar
X74B623CBW7TB85
 
Posts: 10
Joined: Tue Jun 03, 2014 7:48 pm

Re: void loop()

Post by X74B623CBW7TB85 »

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.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: void loop()

Post by adafruit_support_bill »

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.

User avatar
X74B623CBW7TB85
 
Posts: 10
Joined: Tue Jun 03, 2014 7:48 pm

Re: void loop()

Post by X74B623CBW7TB85 »

You stated before
adafruit_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.
and you take it back now here
adafruit_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.
I am not attempting to be rude here


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

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: void loop()

Post by Franklin97355 »

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.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: void loop()

Post by adafruit_support_bill »

What I said was: You can have multiple loops:

Code: Select all

for(...)
{
}

for(...)
{
}
And you can have nested loops

Code: Select all

for(...)
{
   for(...)
   {
   }
}
but you cannot have 2 loops running in parallel. There is no contradiction there.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”