Hi, try this: http://support.apple.com/kb/HT1212
The following is a part of the content that could be found in the link I posted above:
Connecting the device may result in this error message: "iTunes could not connect to the [device] because it is locked with a passcode. You must enter your passcode on the [device] before it can be used with iTunes."
-Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
-Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.
-While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
-Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears, release the Home button.
-iTunes should alert you that it has detected a device in recovery mode. Click OK, and then click Restore to restore the device.