That is the situation I faced when mounting a Raspberry Pi to a base. This was a revision B model with no mounting holes. Lego to the rescue.
Others have used Lego components as standoffs or spacers (see Lego Standoffs). However, the ones I have seen either are used in applications where mounting holes exist, or involve simply drilling a hole through the side of a Lego brick and using it as a spacer. Not very elegant.
The standoffs described in this Instructable can be used to mount circuit boards with our without mounting holes and look pretty good too.
Step 1: Fabrication of Lego Standoffs
Note: These instructions are for use with 3 mm metric mounting screws. If you wish to use ANSI screws, use 4-40 and a #31 or #32 drill for the holes in the bricks. A 1/8 in (0.125 in) drill works well for the clearance holes in the mounting base.
(1) Hold the brick with a pair of pliers and drill a 3 mm hole through the center of the Lego snap post. This works best using a hand drill and going through the underside of the brick, where a preexisting hole left from the molding process leaves a small blind hole that is perfect for guiding the drill through the center of the snap post (Figure 1).
(2) Hold the brick next to the circuit board to gauge how thick the snap post must be. It needs to be slightly shorter than the width of the circuit board.
(3) Rub the post against a piece of sandpaper (180-220 grit works fine) to remove material until the desired post thickness is achieved (Figure 2).
Note: Rotate the brick around as you sand to try and get the post height to be the same all around.
The standoff is ready to use.
Step 2: Using the Standoffs
(1) If the circuit board has mounting holes, mark and drill holes slightly larger than the mounting screw diameter (3 mm) in the mounting base that match the circuit board hole pattern.
(2) Place the Lego standoffs over the holes in the base and set the circuit board on top of them so the holes line up.
(3) Run a 3 mm machine screw with a washer made of nylon or other non-conductive material through the board and the standoffs so that at least 4-5 threads protrude on the underside of the mount.
(4) Install washers (they don't have to be non-conductive) and nuts on the end of the machine screws and gently tighten them to secure the board to the base.
Caution: Do not over tighten the screws.
Instructions for Boards with No Pre-existing Mounting Holes
(1) Place the Lego standoffs on the mounting surface in a pattern that supports the edges of the circuit board. Find places on the circuit board where no components, lands, or traces exist.
Note and Caution: It is usually possible to find component and circuit free locations near the edges of circuit boards, but if needed, the standoffs can be installed over circuit traces but NOT COMPONENTS.
(2) Set the circuit board on the standoffs so that the edges of the board are butted up against the sides of the Lego brick snap posts and not on top of them. Move the standoffs around and use as many as are needed to firmly support the circuit board (Figure 3).
(3) Use a pencil or marker to carefully mark two sides of the final location of each standoff (Figure 4).
(4) Using your best judgement, drill holes where your marks indicate the center of each standoff is located. Use a drill slightly bigger than 3 mm to allow some room for adjustment in the final position.
(5) Run a 3 mm machine screw with a washer made of nylon or other non-conductive material through the each standoff and install them on the mounting board. At least 4-5 threads should protrude on the underside of the mount.
(6) Attach washers (they don't have to be non-conductive) and nuts to the ends of each screw so the standoffs don't wiggle around too much but are not tight.
(7) Place the circuit board on the standoffs so that the edges of the circuit board are under the non-conductive washers and butted against the sides of the Lego snap posts. Notice that the standoffs use clamping action to secure the board in the space under the con-conducting washers.
(8) Gently tighten the screws and nuts until the circuit board is firmly fastened in place.
Caution: Do not over tighten the screws. If the screws are overtightened, it is possible that the Lego snap post will be damaged to the point where metal screw threads could come in contact with the circuit board.
That ought to do it (Figure 5).
If you want to be super certain that no short circuits are introduced by the metal screws, you can use screws and nuts made of non-conducting material. If you are careful this shouldn't be necessary.
In case a standoff does get damaged and the screw threads protrude through the side of a snap post, wrap the snap post with a small piece of Teflon tape.