Color Codes – Different color wires serve different purposes, like:
Black : Hot wire, for switches or outlets.
Red : Hot wire, for switch legs. Also for connecting wire between 2 hardwired smoke detectors.
Blue and Yellow : Hot wires, pulled in conduit. Blue for 3-4 way switch application, and yellow for switch legs to control fan, lights etc.
White : Always neutral.
Green and Bare Copper : Only for grounding.