Multiple Sketches on one UNO

Some time ago I posted a query asking for advice on combining two or more sketches together in order to make better use of the Arduino Uno that I was using. I was advised to consider “merging” of the two sketches.
This I tried but it didn’t meet my requirements as I want to be able to run the separate sketches simultaneously not consecutively and if I merge two sketches together any delay commands affect the other sketch.
The sketches are related to a model railway layout and I don’t want to have numerous Arduinos around the layout when one Arduino has the capacity to control multiple lights, signals etc.

Gareth

if I merge two sketches together any delay commands affect the other sketch.

So, don't use delay(). There are other ways (see the blink without delay example) to periodically perform actions without the need to use delay().

mcnaugg:
I want to be able to run the separate sketches simultaneously not consecutively and if I merge two sketches together any delay commands affect the other sketch.

imagine I ask you to repeat HELLO 10 times, I'm sure you can do that
imagine I ask you to repeat WORLD 10 times, I'm sure you can do that

those are two different tasks

Now what would it take to hear HELLO WORLD 10 times?

if you apply the instructions for a single word you would need two mouths and synchronize them so that they don't speak at the same time...

Now if you work hard you can see that the instructions are simple, just "repeat HELLO WORLD 10 times"..

To get there you thought about what would need to happen and you changed the instructions, merged the programs.

that's the same thing with your arduino.... you need to write a new program which takes into account the asks from the first and second programs.

alternatively you can get 2 arduinos (the 2 mouths) and add a bit of synchro code so that they do the right thing... usually that option is more complicated than writing a new program

Thank You. I should have read more of the examples. I think that "Blink without Delay" will give me the start that I need.
Again Many Thanks.

You can also have a look at:

"Several Things at a Time" seems to cover all of the queries that I have. Now I have to settle down and follow what is shown.

"Planning and Implementing a Program" also has pointers that I need to understand.

Many thanks.