Git Product home page Git Product logo

throttle's Introduction

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!

throttle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

throttle's Issues

ledState not declared in example code

Output from Arduino editor when compiling example:
pulluptest: In function 'void setup()':
pulluptest:13: error: 'ledState' was not declared in this scope
digitalWrite(LED_PIN, ledState);
^
pulluptest: In function 'void loop()':
pulluptest:20: error: 'ledState' was not declared in this scope
ledState = !ledState;
^
'ledState' was not declared in this scope

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.