Reading the logic state of square wave signal from a Hall Sensor

I want to control the output rotation (in deg) for motor/gearbox combination.

I am using a DC motor coupled to a planetary gearbox and a slew drive (datasheets attached). The motor has a Hall pulse sensor (outputs a square wave) which I want to use to control through what angle the motor rotates.

What I would like to do is: The gear-motor output needs to move 1 deg therefore I must provide power to the motor for 200 Hall pulses (or some other arbitrary numbers).

The Hall pulses are at roughly 70 Hz.

I have tried to use the pulseIn() function, but I don't want a pulse duration, I rather want to count the number of logical HIGH's or LOW's directly.

Are there any other functions that can count the Logic state of a digital pin fairly rapidly (I have tried to look for a few hours)?

Thank you! :slight_smile:

24H.30.33-REV.B[3].pdf (102 KB)

PE3C-62-R-24H.30.33-REV.C.pdf (165 KB)