Two programs same time

How to run two independent programs at same time in arduino uno ?

Get a second Uno.

The Uno can't run multiple programs at once. It doesn't have an operating system, which is what you need to manage tasks and processes like that.

You will need to combine your two programs into one.

ok thanks for info but what are the results if i combine two programs in one ?

That depends on what the programs are, and how you combine them.

You will effectively need to write a single new program containing the important parts of the two programs you have currently.

ok i will try it thanks. currently i am trying to combine the blinking led and serial print program. and the problem is when i put delay in blink the next command of serial print is trigger after that delay period.

That's because you shouldn't be using delay.

Don't use delay then. Look at the BlinkWithoutDelay example in the IDE to see how it's done.

Ok thanks all Now i found the reason > Using delay() has a (usually not intended) sideeffect - the Arduino does nothing for that while. To get two or more "actions" to run independent of each other, you can not use delay().

We know:

The loop() runs endlessly and very fast.
digitalRead will look at the input at the time it is called only, likewise digitalWrite and output.
delay() will wait - it stops everything (except interrupts) while we count the milliseconds

Thanks all to giving information and thanks arduino Playground .

Two solutions (both involve writing code that doesn't use the delay() function):

  1. Rewrite your code to do several things at once. See the blinkWithoutDelay example to get started.

  2. Split your program into two or more tasks that individually execute very quickly, but need to be run at particular times; then use a cooperative scheduler to orchestrate the tasks.