To provide a magnetic sensor which is small-sized but highly accurate by effectively suppressing DC offset with a single coil.
A predetermined voltage and a ground are alternately connected to a resonance circuit in which a coil and a capacitor are connected in series. Furthermore, two free wheel diodes are provided, an electromotive force which is generated from the coil just after disconnection from the voltage or the ground is passed through, charges are accumulated in the capacitor and the circuit is stabilized. Both end voltages of a load comprised of the capacitor or connecting the capacitor and the coil in series are acquired thereafter, a voltage under a state of the same polarity of a magnetic field by the coil current and an external magnetic field is compared with a voltage under a state of inverse polarities, and the presence/absence and direction of a magnetic field is detected. Further, in order to improve a temperature characteristic, a period is provided during which the capacitor is charged and discharged perfectly by a sequencer.