This is a simple pinhole lens and cap attachment for a Nikon camera with an f-mount bayonet style mount.
This was inspired by http://www.thingiverse.com/thing:6831 designed by xjcrawler01. I couldn't get this thing to fit, so I designed my own in openSCAD so I could tweak and reprint.
This pinole lens fits on a Nikon camera (it worked on my D7000) like a regular lens. You affix a separately made pinhole over the small aperture using black electrical tape. A simple and easy, but very good pinhole can be made by the "beer can" method.
The parametric OpenSCAD files are included, along with some dependencies to use rotate_extrude to make arcs, and dependencies to make the Nikon male f-style bayonet mount. I also included the dependency for an female f-style bayonet mount. With this, and a little ingenuity, you could make extender tubes for a homemade macro lens, for instance. I will try to knock one of those up soon. I tested both mounts with my lens and camera. The designs come from my measurements, so you might need to tweek/sand a little for your camera.
"Beer can" method to make a pinhole
There is lots of good stuff on this on the web, so do a search. The basic method is to use a piece of aluminum from a beer can (say 1 cm x 1 cm). Use a punch or nail to make a small dent in the aluminum. Then sand the high side of the dent until a hole forms.
To take a picture
Put the camera on a tripod or table. Set the camera to manual, ISO to 100 or 200, and exposure time to 0.5 seconds if in bright sun, 2 or more seconds indoors. Better to use a remote if you have one. Adjust the exposure time and camera position until you get a picture you like.
There are tons of great resources on the web. So explore and enjoy!
Cameras are expensive, and this is not an authorized Nikon accessory. If you decide to print this thing, you use it at your own risk.