NEED HELP to Program a Batching System

but if i am trying to connect multiple relay it does nothing only relay 1 is working.

You don't have anything in your code that looks like "relay 1". You have rly and rly2 (why not the more logical rly1 and rly2?).

So, what actually works?

  pinMode(rly, OUTPUT);
  pinMode(rly, OUTPUT);

Hmmm...