Saw 2-by-6-inch lumber into enough pieces for a frame that's your desired size. For a twin bed, the frame should be at least 42 inches by 78 inches. A full frame should be at least 57 inches by 78 inches. A queen frame should be at least 63 inches by 83 inches, and a king frame should be at least 79 inches by 83 inches. The bed can be any height that you want. Determine this height, subtract 5 1/2 inches, and cut a leg to that size.
Cut 2-by-2-inch lumber into the two rails that will support the bed slats. The support rails should measure the inside length of the frame, which will be 3 inches shorter than the length of the frame that you determined in step 1. So, for example, the length of the support rails for a twin or full frame will be 75 inches.
Divide 2-by-4-inch boards into at least four slats that measure the inside width of the frame, which will be 3 inches shorter than the total width of the frame. Your mattress will rest on these slats.
Use a stud-finder, and mark the location of the wall studs along the walls where you will attach the bed.
Assemble the bed frame by butting the first side rail and head rail perpendicular to each other, placing 3-inch countersunk screws through the side rail and into the head rail. Repeat with each corner. The head and foot rails should be between the side rails, flush with the edge.
Screw the bed frame into the studs on each wall, using 3-inch countersunk screws, supporting it on the unattached corner with the leg piece secured to the bottom of the frame. Use wood glue and a flat bracket.
Fix the slat support rails into the frame of the bed, screwing them into the side rails, using 3-inch countersunk screws.