Question: Read the on-line reference articles A Guide to Debouncing by Jack Ganssle (part I and part II,http://www.ganssle.com/debouncing.htm). Write a subroutine to read the logical state

Read the on-line reference articles A Guide to Debouncing by Jack Ganssle (part I and part II,http://www.ganssle.com/debouncing.htm). Write a subroutine to read the logical state of the input pin associated with the button (open or closed) and return the debounced button state. To check (read the pin state) use

P2->IN & BIT4

If this is 1 it means that the pin on Port2 Bit 4 is high. Normally the pin is high (Pulled up) and when the button is pressed it goes low (more about this in the coming lectures)

  1. Your subroutine must handle switch bounce. When your subroutine detects a button press, it should delay for an appropriate number of milliseconds (5ms) before checking the state again to ensure that the state has not changed. For now we will use the built-in delay function delay_cycles ( );

  2. Write your delay function so that you can adjust the delay to accommodate longer or shorter switch bounce times as appropriate.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!