Need help to use if function in Node Red

Welcome to the forum!

It's helpful to explain what the flow is suppose in detail. i.e. what should happen when the input is a 1 and what should happen when it is a 0?

What do you mean by it seem it’s not stable and it will stop running at some point?

You could use a pair of inject buttons for testing and I'd suggest adding in several debug nodes so you can see what the data is that is passed thru the flow.

If you want someone to help, make sure to answer all questions that are asked and it's also a good idea to export the flow and attach it to a reply (read this thread first)