To adjust the Auto ISO on the Nikon D40, you need to go into the third menu, with the pencil icon. This is the Custom Setting menu.
Scroll down to item 10 and you find the ISO Auto. Press OK to go in and set ISO Auto to On.
You can also set the Max sensitivity, which means the maximum ISO that will be used in low light conditions. Keep in mind that the image quality will degrade as you increase the ISO values. At high ISO values, you will get slightly more grainy pictures Use lower values to keep image quality high and higher values to use in very low light. For the D40, I find ISO 800 to be a good compromise.
The other option is to set the Minimum shutter speed. This is the threshold that will cause the camera to start pushing ISO up. The D40 will try to strike a compromise between noise caused by high ISO settings and blur caused by camera shake caused by low shutter speeds. Obviously this will depend on the focal length, but somewhere around 1/30 should be a good start. You can set a slower shutter speed if you have a steady hand (for example 1/15) or a higher speed if you have a shaky hand (for example 1/60).