How to use the pigpio.Gpio.PUD_DOWN function in pigpio

To help you get started, we’ve selected a few pigpio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HackerShackOfficial / Smartphone-Doorlock / doorlock.js View on Github external
var motorPin = 14;
var buttonPin = 4
var ledPin = 17

var blynkToken = 'blynk_token_here';

// *** Start code *** //

var locked = true

//Setup servo
var Gpio = require('pigpio').Gpio,
  motor = new Gpio(motorPin, {mode: Gpio.OUTPUT}),
  button = new Gpio(buttonPin, {
    mode: Gpio.INPUT,
    pullUpDown: Gpio.PUD_DOWN,
    edge: Gpio.FALLING_EDGE
  }),
  led = new Gpio(ledPin, {mode: Gpio.OUTPUT});

//Setup blynk
var Blynk = require('blynk-library');
var blynk = new Blynk.Blynk(blynkToken);
var v0 = new blynk.VirtualPin(0);

console.log("locking door")
lockDoor()

button.on('interrupt', function (level) {
	console.log("level: " + level + " locked: " + locked)
	if (level == 0) {
		if (locked) {
github nebrius / raspi-gpio / src / index.ts View on Github external
export interface IConfig {
  pin: number | string;
  pullResistor?: number;
}

interface INormalizedConfig {
  pin: number | string;
  pullResistor: number;
}

export const LOW = 0;
export const HIGH = 1;

export const PULL_NONE = Gpio.PUD_OFF;
export const PULL_DOWN = Gpio.PUD_DOWN;
export const PULL_UP = Gpio.PUD_UP;

function parseConfig(config: number | string | IConfig): INormalizedConfig {
  let pin: number | string;
  let pullResistor: number;
  if (typeof config === 'number' || typeof config === 'string') {
    pin = config;
    pullResistor = PULL_NONE;
  } else if (typeof config === 'object') {
    pin = config.pin;
    pullResistor = config.pullResistor || PULL_NONE;
    if ([ PULL_NONE, PULL_DOWN, PULL_UP].indexOf(pullResistor) === -1) {
      throw new Error('Invalid pull resistor option ' + pullResistor);
    }
  } else {
    throw new Error('Invalid pin or configuration');

pigpio

Fast GPIO, PWM, servo control, state change notification, and interrupt handling on the Raspberry Pi

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis