Wiring a barn for lights and receptacles is not difficult but it does take a little thought and planning to get it right. You need to calculate the lighting loads and the receptacle loads to determine the size of the sub panel that you will need to install. You also need to determine if the main service panel has the capacity to handle this added load. Unless you can calculate the electrical loads present on your service panel, you may want to have a professional assess the capability of the service panel to handle the new loads. In order to make the assessment you need to know how to apply derating factors for types of loads, and identify other conditions that affect load calculations.
Install the underground feeder and sub panel
Dig a trench 18 inches deep per National Electrical Code (NEC) requirements from the barn to the building where the main service panel is located. Get as close to the structures as possible with the backhoe or trencher and then finish up with the trenching shovel.
Cut the pieces of conduit to length and glue them together as follows. The Factory 90 goes in the trench; the LB connects to the nipple feeding the cable through the structure's walls. You must protect the cable with conduit where it leaves the ground and enters the buildings per NEC rules.
Cut 2 and 1/2 inch holes through the walls with the hole saw and install the conduit and feeder cable. Cut the cable long enough to reach the main lugs in the sub panel and the 2-pole breaker and neutral/grounding bars in the service panel.
Mount the sub panel as close to the point of entry as possible. Secure the feeder cable in the top center knockout with a cable connector. Remove the cables outer jacket with razor knife. Cut the red and black insulated conductors long enough to reach the main Buss Bar lugs. Strip them and secure them under the compression screws. Connect the white wire to the neutral bar and the bare wire to the ground bar.
Turn off the main service disconnect and install the two-pole breaker in the service panel. Install and connect the feeder cable. Connect the red and black circuit conductors to the circuit breaker. Connect the white wire and bare wire to the service panel's neutral/ground bar. Secure the new breaker in the off position and turn on the main disconnect
Install the receptacle and lighting branch circuits
Mount the device boxes for the duplex receptacles and light switches. Mount the receptacle boxes 48 inches above the floor and the light switch boxes 46 inches above the floor. Mount the receptacle boxes so that no point along the wall is more than 10 feet from a receptacle and limit the number of receptacles to five per 20-ampere branch circuit.
Mount the lighting outlet boxes. Figure a lighting load of 1 and ½ watts per square foot of floor space.
Install one 20-ampere circuit breaker for each 5 receptacles and one 20-ampere circuit breaker for each branch circuit for lights. Run one length of 12/2 NMC cable for each receptacle and lighting branch circuits. Connect the black circuit wires to the circuit breakers, the white wire to the neutral bar, and the bare wire to the grounding bar.
Connect the receptacles. Strip 3/4 inches of insulation from the ends of the wires and make a loop in them with the needle nose pliers. Secure the black wire and the white wire under the brass and silver screws, respectively. Connect the bare wires to the green screw.
Connect the light switches. Attach the black wire from the sub panel to the bottom brass screw and the black wire to the lights to the top brass screw. Attach the bare copper wire to the green grounding screw. Splice the two white wires together by twisting them together with the Lineman's pliers and screwing on a wire nut.
Install the lighting fixtures by splicing the fixture wire to the matching color circuit wires. Secure the fixtures to the boxes.