How to use pigpio - 10 common examples

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 bang-olufsen / create / Beocreate2 / beo-extensions-experimental / led / index.js View on Github external
function initialise(red, green, blue) {
		if (red && green && blue) {
			pigpio.configureClock(10, pigpio.CLOCK_PWM); // Configures PiGPIO to use PWM as clock source (by default it uses PCM which conflicts with BeoCreate 4-Channel Amplifier).
			pigpio.initialize(); // pigpio C library initialized here
			
			ledR = new pigpio.Gpio(red, {mode: pigpio.Gpio.OUTPUT});
			ledG = new pigpio.Gpio(green, {mode: pigpio.Gpio.OUTPUT});
			ledB = new pigpio.Gpio(blue, {mode: pigpio.Gpio.OUTPUT});
			ledInitialised = true;
			beoBus.emit("general", {header: "requestShutdownTime", content: {extension: "led"}});
			return true;
		} else {
			return false;
		}
	}
github bang-olufsen / create / Beocreate2 / beo-extensions-experimental / led / index.js View on Github external
function initialise(red, green, blue) {
		if (red && green && blue) {
			pigpio.configureClock(10, pigpio.CLOCK_PWM); // Configures PiGPIO to use PWM as clock source (by default it uses PCM which conflicts with BeoCreate 4-Channel Amplifier).
			pigpio.initialize(); // pigpio C library initialized here
			
			ledR = new pigpio.Gpio(red, {mode: pigpio.Gpio.OUTPUT});
			ledG = new pigpio.Gpio(green, {mode: pigpio.Gpio.OUTPUT});
			ledB = new pigpio.Gpio(blue, {mode: pigpio.Gpio.OUTPUT});
			ledInitialised = true;
			beoBus.emit("general", {header: "requestShutdownTime", content: {extension: "led"}});
			return true;
		} else {
			return false;
		}
	}
github HackerShackOfficial / Smartphone-Doorlock / doorlock.js View on Github external
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) {
			unlockDoor()
		} else {
			lockDoor()
github HackerShackOfficial / Smartphone-Doorlock / doorlock.js View on Github external
var unlockedState = 1000;
var lockedState = 2200;

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) {
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 bang-olufsen / create / Beocreate2 / beo-extensions-experimental / led / index.js View on Github external
function initialise(red, green, blue) {
		if (red && green && blue) {
			pigpio.configureClock(10, pigpio.CLOCK_PWM); // Configures PiGPIO to use PWM as clock source (by default it uses PCM which conflicts with BeoCreate 4-Channel Amplifier).
			pigpio.initialize(); // pigpio C library initialized here
			
			ledR = new pigpio.Gpio(red, {mode: pigpio.Gpio.OUTPUT});
			ledG = new pigpio.Gpio(green, {mode: pigpio.Gpio.OUTPUT});
			ledB = new pigpio.Gpio(blue, {mode: pigpio.Gpio.OUTPUT});
			ledInitialised = true;
			beoBus.emit("general", {header: "requestShutdownTime", content: {extension: "led"}});
			return true;
		} else {
			return false;
		}
	}
github bang-olufsen / create / Beocreate2 / beo-extensions-experimental / led / index.js View on Github external
function terminate() {
		turnOff();
		pigpio.terminate(); // pigpio C library terminated here
		beoBus.emit("general", {header: "shutdownComplete", content: {extension: "led"}});
	}
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 HackerShackOfficial / Smartphone-Doorlock / doorlock.js View on Github external
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) {
			unlockDoor()
github fivdi / pi-io / lib / pi-io.js View on Github external
function PiIO() {
  LinuxIO.call(this, {
    name: 'Pi-IO',
    pins: pins,
    defaultI2cBus: 1,
    defaultLed: 'LED0'
  });

  pigpio.initialize();

  // After explicitly calling pigpio.initialize wait 100ms for pigpio to become
  // ready for usage. This delay is necessary for alerts to function correctly.
  // See https://github.com/joan2937/pigpio/issues/127
  // Update: This issue was fixed with pigpio V63 in May 2017. When Raspbian is
  // updated to include pigpio V63 the timeout here can be removed.
  setTimeout(function () {
    this.emit('connect');
    this.emit('ready');
  }.bind(this), 100);
}
util.inherits(PiIO, LinuxIO);

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