Need help with programming for my project

Wire the 9 switches in series and you only need 1 digital pin and the same code you have written.