...i was playing with my nikon d40...
Just a quick heads up about an issue that a number of Nikon DSLRs have when used for astrophotography. Check out my post here
. The D40 isn't mentioned but you could easily check if it is affected by doing a shot of some star trails (5 minute exposures on a tripod should do it with a small enough f-number to prevent sky-glow from nearby street lamps being visible in the picture). Do one shot with the camera operating normally and once it has finished doing whatever it needs to do then give the sensor a couple of minutes to cool down and do a second shot with identical settings but trying "Mode 3" as described by Christian Buil as referenced in that post.
Of course, non of the above applies if you don't want to use the camera for long exposures. Even if you do, the Mode 3 workaround fixes the issue, albeit at the cost of some mental stress in turning the camera off while it's doing something!