Practice / Hardware & Robotics

Debounce a button in C

Medium · Coding (typed)

A push button (active low, with a pull-up) bounces for up to 10 ms. Write C code that reports one "pressed" event per real press. You have a 1 ms timer interrupt and a function read_button_pin() that returns 0 or 1.

Create a free account to answer it and get scored on what a strong answer covers.