programming relay shield

Hello Please, I want a program to Shield has 8 relay when using switch on pin No. 0, for example, All relays operate sequentially after time 5 seconds each of them to keep working to that Turn off this switch, If you connect another switch on pin No. 2 only work relays No. 1, 3, 5, 7 sequentially duration time 5 seconds each .