Can I animate an objects material?

I have several stacks of cubes that are going to be a volume meter for music I’m adding later. I have created several materials for the different colors of the cubes: gray for blank, green for the bottom ones, red for the top, etc.

I want to be able to animate which material is applied to the cube at a given point. For example, frame 10 might have cube 3 with the gray material but frame 12 might see it with a red texture.

Is there a way I can do this?

material change .blend (473 KB)
materials and textures are two separate things. I know you can animate just about anything if you hover your mouse over the property and press the “I” key.
Okay, just tried it out, looks like you can animate both. I set the keys to constant so there wouldn’t be any transition.
hope that helps