for loop how to use index

For a start you haven't got a complete program that will compile.

And (sensor + i) won't do what I guess you think it's doing. Neither will (buttonstate + i) nor even buttonstatei

Look up arrays https://www.arduino.cc/en/Reference/Array and then start using them like it says.

Steve