If so, please tell me and also tell me if any interfacing of other microcontroller needed?

  • 2
    Please read How do I ask a good question?. More details give you a better answer. Is this something slow (eg. detecting a window opening) or something fast (eg. a magnet on a bicycle spoke)? What are you trying to achieve? – Nick Gammon Feb 18 '16 at 4:47

I can't comment yet but you probably are looking for a hall effect sensor.

Something like this is a simple version of the sensor. https://www.sparkfun.com/products/9312

You can then do a digitalRead on the DO pin to detect if a magnet is near the sensor.

You would connect the Vdd to 5v arduino supply and GND to the GND of the board.

  • 1
    Just note that there are different kind of hall-effect sensors. Some respond only to one polarity (i.e. only North or only South). Some will give a on-off value (i.e. magnet present/magnet not present), while others can give an analog value proportional to the magnetic field present. Choose the one most suitable to your project. – Gerben Feb 17 '16 at 17:00

If you don't care about measuring the strength of the magnetic field, you can use a magnetic switch (sometimes called a reed switch). A magnetic switch closes when a magnet is put up to it and opens when there is not. The only problem with this is that the magnet has to be within about one inch from the switch. The magnetic switch works just like a normal switch and usually has two contacts. Here is an example.

Not the answer you're looking for? Browse other questions tagged or ask your own question.