Skip to content

Button debounce library for Raspberry Pi Pico (RP2040 and RP2350)

Notifications You must be signed in to change notification settings

TuriSc/RP2040-Button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pico-button.c

Installation

Install with clib(1):

$ clib install jkroso/pico-button.c

Api

create_button(pin, onchange): It will set the pin to pull up. It returns a button_t struct

typedef struct button_t {
  uint8_t pin;
  bool state;
  void (*onchange)(struct button_t *button);
} button_t;

Example

#include "pico-button/button.c"

void onchange(button_t *button_p) {
  button_t *button = (button_t*)button_p;
  printf("Button on pin %d changed state to %d\n", button->pin, button->state);
}

int main() {
  stdio_init_all();
  button_t *b = create_button(21, onchange);
  printf("Button created and it's state is %d\n", b->state);
  while (true) tight_loop_contents();
  return 0;
}

About

Button debounce library for Raspberry Pi Pico (RP2040 and RP2350)

Resources

Stars

Watchers

Forks

Languages

  • C 88.2%
  • CMake 11.8%