don't use an analog sensor but a digital one and connect it to the attach interrupt.
Often used constructs are a small magnet and a hall sensor. if you search for "hall sensor arduino " you will get enough hits...
don't use an analog sensor but a digital one and connect it to the attach interrupt.
Often used constructs are a small magnet and a hall sensor. if you search for "hall sensor arduino " you will get enough hits...