Above is a wiring diagram for a standard, 3-way lamp switch. This socket is used with a three way bulb containing 2 separate elements that are energized separately and then together as the switch knob is turned, for varying degrees of light.
A hardwired doorbell includes a small transformer that converts the household alternating current (AC), to direct current (DC) for the doorbell chimes. A small, 16 awg wire runs from the door button to the chimes. When pressed, the button will send the transformer output through the chimes, sounding the bell until it is released.
This diagram is similar to the one above, but the switch comes before the new light in the circuit. New cable is run from the receptacle to the new switch location and from there to the light location. The switch may also be added in the the same box with the receptacle as in the diagrams at this link, where the two are installed in a double-gang electrical box.
The always-hot wire from the receptacle is spliced to the black wire on the fixture cable, and to a pigtail that connects back to the hot terminal on the receptacle. At the light fixture box, the black is spliced to the black from the switch cable. At the switch box the black wire is connected to the bottom terminal on the new switch.
Another, more permanent, repair for an old doorbell circuit is to use a small ac adapter in place of the battery. Most people will have an AC adapter left after an old radio or similar device has long since died. Look for an output of 10 to 16 volts printed on the side of the adapter casing. Current ratings will typically be very low from these adapters, around 500mA, making them perfect to power the doorbell circuit. All that is needed is a conveniently located receptacle to plug the adapter in.
The white wire on the switch loop is used to carry current from the source to the switch and it is marked with black tape or paint to label it as hot. The black on the switch loop runs from the top switch terminal to the top half of the receptacle. With this arrangement the top half of the duplex is controlled with the switch and the bottom half is always hot.
This page contains wiring diagrams for a service panel breaker box and circuit breakers including: 15amp, 20amp, 30amp and 50amp, as well as a GFCI breaker and an isolated ground circuit.
With this lamp, bulb A can be turned off and on independently and switch B can turn on bulb 1 alone, bulbs 2 and 3 together with bulb 1 off, bulbs 1, 2 and 3 all on at the same time or all three off.