Many colours, shades and hues exist on the colour wheel, and you can use any of these to help decide how to mix and match paint and carpet colours. Consider extreme ways to mix and match, and examine some more subtle ways as well. Variation is always important in choosing colour for any room, but the amount of variation is up to the decorator.
Matching paint and carpet colours exactly is not a sensible idea. By matching carpet and paint exactly, the room loses dimension and depth. The best method is to either make the walls lighter than the carpet or vice versa. Also, don't match carpet or paint to furniture colours, which also detracts from the dimensions of the room.
Some people use different coloured carpets in different rooms. Determine how the colours of the carpet look against each other. They should not vary too much, and pay attention to how carpet colours look against other walls. For example, if the carpet is brown in one room and the walls are green, that works well, but if the room across the hall has grey walls, the brown carpet won't look as good with that colour.
Use a colours scheme to match carpet and paint colours. One is the monochromatic colour scheme, which uses different shades of one colour. This is useful if you want your walls and carpet to look similar but not the same. Adjacent colour schemes use different colours that lie next to each other on the colour wheel, which can mean using blue and blue-green, for example. Another scheme is called the complementary colour scheme, which uses colours that are complementary, or that lie directly across from each other on the colour wheel. An example of this is purple and yellow, or blue and orange. Variations of this colour scheme involve using even more colours that are complementary. The triadic colour scheme uses three colours that are an equal distance from each other on the colour wheel. Last is the neutral colour scheme that includes whites, blacks and greys. You can use all of these to balance the colour choices in a room and to help guide what paint colour to use with which carpet colour.