Skip to content

Event and onoff-based NodeJS lib that serves rotary encoder data from GPIO pins on Raspberry Pi

License

Notifications You must be signed in to change notification settings

smallab/nodary-encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodary-encoder

Based off https://github.com/nstansby/rpi-rotary-encoder-python & https://github.com/pichfl/onoff-rotary: event-based NodeJS lib that relies on https://github.com/fivdi/onoff to get rotary encoder (such as https://thepihut.com/products/rotary-encoder-extras) data from GPIO pins on Raspberry Pi.

Installation

npm i nodary-encoder --save

Usage

Nodary Encoder schematics

const nodaryEncoder = require('nodary-encoder');
const myEncoder = nodaryEncoder(17, 18); // Using GPIO17 & GPIO18

myEncoder.on('rotation', (direction, value) => {
  if (direction == 'R') {
    console.log('Encoder rotated right');
  } else {
    console.log('Encoder rotated left');
  }

  console.log('Value is', value);
});

About

Event and onoff-based NodeJS lib that serves rotary encoder data from GPIO pins on Raspberry Pi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published