If you want to be really methodical, try an experiment along these lines:
On a sunny day, take a bunch of photos of the same stationary object. Keep everything the same except your shutter speed (go into manual mode). Start with your camera on the fastest setting (which leaves the shutter open for the shortest amount of time [1/4000 of a second on the D40?]) and move down to the slowest (30 seconds on the D40), taking a picture at every point on the way.
You`ll find that a lot of the fastest speeds produce an image that`s too dark because the shutter will have been open for too short a time to let enough light onto the image sensor. A lot of the slowest speeds will be blurred (from your shaking hands) and/or too bright (from too much light hitting the sensor).
Do the same experiment standing in the shade (i.e. out of direct sunlight), at sunset/dusk and at night. Do all of the above with subjects that are moving slowly (instead of being stationary) and ones that are moving more quickly.
You can save a lot of time by looking at your pictures on the D40`s LCD. So, for example, when you find that 1 second is way too bright in certain light, you won`t have to bother going further.
In general, if everything else stays the same, you need longer exposure times in lower light. You need shorter exposure times when your subject is moving, and also when you`re not using a tripod, if you want to avoid blurred images.
If you do it methodically and take a look at all these series of pics on your computer (split them into different events or albums on iPhoto), in a single day you`ll be able to see that there`s a different range of good shutter speeds for different subjects in different levels of light. Hit `command` and `i` in iPhoto to bring up information on the shutter speed so you can compare more easily.
I talk about the need to keep all other things equal because there are a number of other factors/settings that will influence your photos and ruin your experiment if you change them. For example:
-aperture. This refers to the size of the opening in the lens that light comes in through. Obviously, a smaller hole means less light hits the sensor, just like only opening the curtains in your bedroom halfway means your it will be more dimly lit. Don`t try this experiment in shutter priority mode because your camera will automatically adjust the size of the aperture and you won`t get useful results; use manual mode.
-ISO
-focal length (how far out are you zoomed?)
You need to read about these concepts because they`re really important. If you do the above, though, it`ll take you a single day to get a much better idea of how changing nothing but the shutter speed affects your photos.