Turn off the power to the circuit in which you are wiring the switch by turning off the main breaker. Use a multimeter to make sure that the power is off. Do not attempt to install the switch with the power on. Doing so could result in damage to the electrical circuit, as well as serious injury to you.
Cut a hole in the wall to accommodate the switch box, or remove and disconnect the existing light switch. Remove the screws that are holding the faceplate to the wall. Pull out the existing switch and loosen the terminal screws with a screwdriver. Remove the wires from the terminal and dispose of the old switch.
Attach the red wire to the other red wire in the switch box.
Loosen the two terminal screws on the switch. Attach one of the black wires to one of the switch terminals. Attach the other black wire to the free switch terminal by inserting the wire into the hole, or bending it to wrap around the switch's terminal screw.
Attach the green wire, or the bare copper wire, to the green bolt inside the switch box.
Push the switch into the hole in the wall. Test to make sure that the switch works correctly.
Screw the face plate back on the wall.