Pinhole cameras are basically just very simple cameras, which have no lens, and a single small aperture opening. In reality, to produce a photograph a complex camera and lens are not necessary. In fact, it is not actually necessary to have a lens at all.
A pinhole camera is essentially a lightproof box, which admits light through one side via a tiny pinhole opening. There is a sheet of film attached to the interior of the pinhole camera, which is opposite to the pinhole. Today’s much more sophisticated cameras are really just elaborations of the pinhole camera, in that they are simply lightproof boxes that allow light to strike a recording medium of some sort, either film or a light sensitive digital sensor.
The shutter of a pinhole camera must be manually controlled with a flap of some sort of lightproof material. Typically lengthy exposure times are needed, which can range anywhere from five seconds to as long as days. This long exposure time makes capturing moving subjects pretty much out of the question under most circumstances, but it can effectively capture for example, a star trail. The long exposure time can also cause reciprocity law failure.
Typically, the smaller the pinhole the sharper the image. However, an extremely small pinhole can actually have the opposite effect, due to the wave properties of light. It’s also important that the pinhole be perfectly round, and made in a very thin piece of material, in order to prevent distortion and “vignetting”, which occurs when there is a reduction in light toward the edges of the pinhole.
For a VERY detailed explanation of all things related to pinhole cameras, I recommend visiting pinhole.cz.
There are companies that actually sell very precise pinholes of various diameters, which are typically made in high grade materials with lasers. However, if you are satisfied with having less control over the final hole size, it is perfectly possible to make your own pinhole out of a piece of soda can and a needle. It is important to make the needle hole as small as you possibly can. In order to estimate your exposure times, it is important to know the f number of the pinhole camera. You can calculate this by dividing the focal length by the diameter of the hole.
If you are interested in making your own pinhole cameras, I just found this very fun article called 23 Pinhole Cameras That You can Build At Home.