Apple has not made it easy to let the iphone communicate with external devices. Basically, you need a jailbroken phone to do anything. This post covers the current state of serial communication on the iphone.
A succesful example of making an application that uses the serialport on the iphone is xGPS, which let you connect to an external GPS.
source: Conversation with spaces