Detect a detachment of an object

Hi everybody,

I have a removable object and I want to know/detect whether this object is detached or attached.

How can I achieve this using arduino?

Thank you. might give you some ideas.

Thank you. I will use infrared for this finally...

Well you have already made up your mind but a reed switch would have been a nice option as well but then again I don't exactly know what kind of application you are working on.

Thank you waqaszahid.

I want to know when a particular object 1 is attached or detached from another particular object 2. When the object 1 is detached (respectively attached), the state "attached" (respectively "detached") will be available only if object 1 is (respectively isn't) on contact with object 2.

User can go everywhere he want with object 1. Can I achieve this with reed switch too?

well if you read the basic functionality of a read switch, it switches state whenever a magnet is brought near it, say if the controller is connected to object2 with the reed switch installed at the right place then you can have a piece of neodymium magnet attached to object1 and whenever the two are brought close the reed switch should work. I am not sure what type of mechanical assembly you are working with but seriously the you can pretty much use anything that suits your application.