How to use the pigpio.Gpio.INPUT 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) {
github fivdi / pi-io / lib / range-finder.js View on Github external
RangeFinder.prototype.pingRead = function (callback) {
  this._callback = callback;
  this._startTick = undefined;
  this._ignoreAlerts = false;

  if (this._singlePin) {
    this._triggerGpio.mode(Gpio.OUTPUT);
  }

  this._triggerGpio.trigger(10, 1);

  if (this._singlePin) {
    this._triggerGpio.mode(Gpio.INPUT);
  }

  this._timeout = setTimeout(function() {
    if (this._singlePin) {
      // Some hc-sr04 sensors appear to hang and don't timeout after 200000
      // microseconds. Setting the pin-mode to output appears to force the
      // timeout to occur.
      this._triggerGpio.mode(Gpio.OUTPUT);

      setTimeout(function () {
        this._callback(0);
      }.bind(this), 100);
    } else {
      this._callback(0);
    }
  }.bind(this), 250);
github fivdi / pi-io / lib / range-finder.js View on Github external
echoGpioNo = triggerGpioNo;
  } else {
    this._singlePin = false;
  }

  this._triggerGpio = new Gpio(triggerGpioNo, {
    mode: Gpio.OUTPUT,
    pullUpDown: Gpio.PUD_OFF,
    alert: this._singlePin
  });

  if (this._singlePin) {
    this._echoGpio = this._triggerGpio;
  } else {
    this._echoGpio = new Gpio(echoGpioNo, {
      mode: Gpio.INPUT,
      pullUpDown: Gpio.PUD_OFF,
      alert: true
    });
  }

  this._callback = undefined;
  this._startTick = undefined;
  this._ignoreAlerts = false;
  this._timeout = undefined;

  this._triggerGpio.digitalWrite(0);

  // If a single pin is used for both trigger and echo there will be alert
  // events for trigger pulses and echo pulses. Trigger pulses are ignored.
  this._echoGpio.on('alert', function (level, tick) {
    let endTick;
github nebrius / raspi-gpio / src / index.ts View on Github external
constructor(config: number | string | IConfig) {
    const parsedConfig = parseConfig(config);
    super(parsedConfig.pin);
    this.pullResistor = parsedConfig.pullResistor;
    this._input = new Gpio(getPin(parsedConfig.pin, this.pins[0]), {
      mode: Gpio.INPUT,
      pullUpDown: parsedConfig.pullResistor
    });
    this._input.enableInterrupt(Gpio.EITHER_EDGE);
    this._input.on('interrupt', (level: number) => setTimeout(() => {
      this._currentValue = level;
      this.emit('change', this.value);
    }));
    this._currentValue = this._input.digitalRead();
  }

pigpio

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

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis