Skip to content

Gruppio/Throttle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Throttle

Throttle library for arduino, just like a debounce but faster!

Advantages

There are already some libraries that perform some functionalities like Throttle. One of the most famous is Bounce, the problem is if that the output of bounce is delayed and if you have to press a button multiple times very frequently is unereliable. With Throttle you will not have any issue ๐Ÿ˜Ž

Compatibility

The Throttle object has the same interface of the Bounceย so you can just replace the instantiation and compile!

Example

// This example toggles the debug LED (pin 13) on or off
// when a button on pin 2 is pressed.

// Include the Throttle library found here :
// https://github.com/Gruppio/Throttle

#include <Arduino.h>
#include <Throttle.h>

#define BUTTON_PIN 2
#define LED_PIN 13

Throttle button = Throttle(BUTTON_PIN, INPUT_PULLUP);

void setup() {
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, ledState);
}

void loop() {
   button.update();
   
   if (button.fell()) {
     ledState = !ledState;
     digitalWrite(LED_PIN, ledState);
   }
}

If you like this project please:

Buy Me A Coffee

Thank you!

About

Throttle library for arduino, just like a Debounce but faster! ๐Ÿ˜Ž

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages