Stepper motors generally comes along with an IC ULN2003. This IC is used to drive motor because microcontroller pins are unable to provide sufficient current to drive these motors.
Set the TAP THRESHOLD to 2.5g. To do that we need to write 40 (2.5/.0625) to the THRESH_TAP Register. This means that you need at least 2.5g acceleration in Z AXIS in order for the tap to qualify as TAP.
UART have a feature called IDLE line detection and we are going to use this to sole the problem mentioned above. Idle line is detected on RX line when there is no received byte for more than 1 byte time length.
The process is pretty straight forward. We will set the data pin as input and count the number of times it goes high and low in 1 second and that will be the input frequency. I am using NE555 to generate different frequencies and DSO138 to compare the results to.