Circuits / Sensors
Arduino UNO: KY-024 magnet counter
The Hall switch turns on at about 160 G and off under about 105 G in the model (hysteresis; real parts differ, and only a south pole counts: turn the magnet over if nothing counts), so a magnet that wobbles near the threshold counts once; the program counts each fall of DO

Tap a part to see its voltages and currents. It is a model, not a measurement.
What do you need?
- Development board Arduino UNOAliExpress Amazon
- Sensor module (LM393) KY-024AliExpress Amazon
- Jumper wires × 4AliExpress Amazon
- BreadboardAliExpress Amazon
The AliExpress links are affiliate links: if you buy through them ohmio.dev gets a commission, at no extra cost to you. Affiliate links
This page is a guide: the numbers come from a simulation, and real parts vary. Check your parts before you power the circuit. Safety and responsibility
How does an Arduino count magnet passes with a Hall sensor?
A Hall sensor reacts to a magnetic field. The KY-024 module is modeled here with an A3144 switch, which turns on when a south pole is strong enough and turns off again when it weakens. In the model that is about 160 G on and about 105 G off. This gap, called hysteresis, keeps a magnet that wobbles near the threshold from counting twice. When the switch turns on, DO falls from 4.98 V to 0.20 V. The program reads DO on D2 every 10 ms, and each time it goes from HIGH to LOW it adds one to the count and prints it. In the test the first pass printed 1 and the second 2. A north pole does nothing: at −300 G DO stays high, so turn the magnet over if nothing counts. Those thresholds are the model's, and the real board may carry a different chip, reportedly a linear 49E.
Values from the Protoboard ISO simulation: a model, not a bench measurement.
Hear about the next circuit
One email when a new circuit is out, about twice a month. Nothing else.