This question already has an answer here:
I'm a total beginner with my Nikon D5100 and i'm trying to shoot in auto mode. When I attach the AF-S Nikkor 18-55 mm lens, the camera says "lens not attached" unless I have it in M (manual) mode. I have checked and the lens is switched to A. Any help would be appreciated!