How to use the pigpio.Gpio 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 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 PacktPublishing / Building-Smart-Homes-with-Raspberry-Pi-Zero / Chapter 04 / motor_control / motor_control.js View on Github external
// Modules
var Gpio = require('pigpio').Gpio;
var express = require('express');

// Express app
var app = express();

// Use public directory
app.use(express.static('public'));

// Create led instance
var motorSpeed = new Gpio(18, {mode: Gpio.OUTPUT});
var motorDirectionOne = new Gpio(14, {mode: Gpio.OUTPUT});
var motorDirectionTwo = new Gpio(15, {mode: Gpio.OUTPUT});

// Routes
app.get('/', function (req, res) {

  res.sendfile(__dirname + '/public/interface.html');

});

app.get('/set', function (req, res) {

  // Set motor speed
  speed = req.query.speed;
  motorSpeed.pwmWrite(speed);

  // Set motor direction
github andywise / drawbot / modules / BotController.js View on Github external
new Gpio(config.pins.rightDir, gmOut)
    ]
    var stepPins = [
        new Gpio(config.pins.leftStep, gmOut),
        new Gpio(config.pins.rightStep, gmOut)
    ]
    // set up servo GPIO pin
    var servo = new Gpio(config.pins.penServo, gmOut)

    // ^ Step resolution Pins
    const leftMotorMs1= new Gpio(config.stepResolutionPins.leftMotor.ms1, gmOut)
    const leftMotorMs2= new Gpio(config.stepResolutionPins.leftMotor.ms2, gmOut)
    const leftMotorMs3= new Gpio(config.stepResolutionPins.leftMotor.ms3, gmOut)
    const rightMotorMs1= new Gpio(config.stepResolutionPins.rightMotor.ms1, gmOut)
    const rightMotorMs2= new Gpio(config.stepResolutionPins.rightMotor.ms2, gmOut)
    const rightMotorMs3= new Gpio(config.stepResolutionPins.rightMotor.ms3, gmOut)

    // ^ Step resolution settings
    // * Were configuring our driver for an Eighth Step resolution. Also note that these pinouts
    // * correspond to the A4988 StepStick stepper motor driver:
    // ? https://www.pololu.com/product/1182
    // 
    // * We're not adjusting the values on the fly so they can be set here and not touched, but if your resolution
    // * needs to vary at runtime you can adjust the values of these pins. More information 
    // * on pin configurations can be found here:
    // ? https://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/
    leftMotorMs1.digitalWrite(1)
    leftMotorMs2.digitalWrite(1)
    leftMotorMs3.digitalWrite(0)
    rightMotorMs1.digitalWrite(1)
    rightMotorMs2.digitalWrite(1)
    rightMotorMs3.digitalWrite(0)
github daaru00 / aws-iot-example / tasks / sensor.js View on Github external
const cron = require('node-cron');
const config = require('../lib/config.js');
const Gpio = require('pigpio').Gpio;

const motor = new Gpio(config.GPIO_SERVO, {mode: Gpio.OUTPUT});

const Sensor = require("../devices/sensor.js")
var sensor = new Sensor({
  "privateKey": config.PRIVATE_KEY,
  "clientCert": config.CLIENT_CERT,
  "caCert": config.CA_CERT,
}, config.HOST, config.DEBUG);

const miHome = require("../lib/mi-home.js");
miHome.load({
  gateway: {
    id: config.MIHOME_GATEWAY,
    token: config.MIHOME_TOKEN
  },
}, {sensor: () => {
  sensor.connect(function () {
github nebrius / raspi-gpio / dist / index.js View on Github external
constructor(config) {
        const parsedConfig = parseConfig(config);
        super(parsedConfig.pin);
        this._output = new pigpio_1.Gpio(getPin(parsedConfig.pin, this.pins[0]), {
            mode: pigpio_1.Gpio.OUTPUT,
            pullUpDown: parsedConfig.pullResistor
        });
        this._currentValue = this._output.digitalRead();
    }
    write(value) {

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