Giter Site home page Giter Site logo

pcint's Introduction

PCINT

Pin Change Interrupt Library

License: CC BY-NC-SA 4.0 Build Status

Arduino pin change interrupt library compatible with AVR and SAM with consistent interface.

Allows handlers to be called with a predefined cargo (void*) for user data or just regular void returning functions with no params.

This library use meta-programing to achieve consistency.

If your board is not supported please see mkPCIntMap example.

Supporting 328, 2560 and due and including example sketch to obtain pin maps for other MCUs.

If you use the example to build maps for other AVR's please let me know (pull request) so that i can include them for benefit of other users. Thanks.

Example

#include <pcint.h>

#define led 13
#define btn 12

void setled() {
  digitalWrite(led,digitalRead(btn));
}

void setup() {
  pinMode(led,OUTPUT);
  pinMode(btn,INPUT_PULLUP);
  PCattachInterrupt<btn>(setled,CHANGE);
  setled();//initial led status
}

void loop() {}

API

PCattachInterrupt

void PCattachInterrupt<pin>(userFunc,mode);

monitor pin and call user function on change.

  • pin - your board pin number
  • userFunc - function to be called on pin change
  • mode - when to call the function, can be CHANGE | RISING | FALLING

PCdetachInterrupt

void PCdetachInterrupt<pin>();

stop monitoring pin change on given pin.

  • pin - your board pin number

History

(Oct 2016) V4.0 changed API to support arduino due.

(Jul 2016) added skectch to print PCINT maps, please pull or send me new maps. This allows you to add support for your board pinout definition.

(Nov.2014) using arduino PCINT macros for wider compatibility

(Sep.2014) Made this because i need a PCINT handler that can have extra data attached.

pcint's People

Contributors

neu-rah avatar

Watchers

 avatar

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.