Can I shoot a photo with my DSLR without the lens on?
I thought it would be interesting to see what kinds of effects I could get by shooting a photo without any lens on my DSLR. However, when I take the lens off, it tells me that no lens is attached (obviously) and it won't let me take a photo. I have a Nikon D3100. Is it possible to do this? Can I change some setting or trick the camera in some way to allow me to take a picture this way?
It's mostly higher-end cameras that allow you to disable this interlock, since it's mostly used for things like digiscoping, where you have a lens (or mirror), but one the camera can't recognize. Without something to focus the light, however, you don't get much in the way of "effects" -- assuming auto-exposure and auto white balance, you'll end up with pretty much a neutral grey picture, almost regardless of what's in front of the camera.
I don't think the oscilloscope cameras I used in college had any sort of lens assembly. IIRC they were just a box with a Polaroid film holder in the back and a manual shutter. Goofing around we did occasionally take pictures of each other or the lab; and aside from being badly out of focus they still worked.
See this awesome answer from a different question, where @Imre gives a great example. :)
You have set it to manual mode (M) although you would need some sort of lens to get any image to appear even if it is digital pinhole lens that you make.
... the you might try to take a picture without a memory card or any other kind of storage. And, as the next step, when it gets truly philosophical: can you take a picture without a camera?
Some lens adapters for old film SLR lenses are just a ring with a chip that overrides the lens sensor. Your results are likely going to be mostly 'artistic' with just a bare sensor.
There are two possible interpretations of this question:
Can you trigger an exposure with the lens removed:
Answer: It's camera specific. Try setting the camera to manual mode. On my Nikon D80, it will not take an exposure with the lens removed except when in full manual ("M" on the mode dial).
Can you take a meaningful or interesting image without something acting like a lens.
This is where things get tricky. For instance, I would argue that anything that projects some sort of pattern of light onto a surface (in this case, the sensor), effectively is a lens. Therefore, unless you want a flat, monochromatic exposure, you have to have some sort of lens.
A pin-hole lens (as described by Hasin Hayder in his answer), is still arguably a lens, even if it is not a refracting lens. As such, you cannot shoot a meaningful image with out some manner of lens, even if it does not communicate with the camera, as lenses specifically designed for your camera do.