So you want to detect whenever an external accessory is plugged into an iPhone/iPad and communicate with that device?
Without using the official API from the developer of that accessory, you'd have to reverse-engineer its protocol, and that might get you into trouble for copyright reasons.
You can get started with using external accessories on iDevices here, though it won't help you much without knowing how to communicate with a specific device.