Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var raspi = require('raspi-io');
var board = new raspi();
// Initialize the board
board.on('ready', function () {
// var Motor1A = 'P1-16';
// var Motor1B = 'P1-18';
// var Motor1E = 'P1-22';
// var Motor2A = 'P1-23';
// var Motor2B = 'P1-21';
// var Motor2E = 'P1-19';
var Motor1A = 'GPIO23';
var Motor1B = 'GPIO24';
var Motor1E = 'GPIO25';
var Motor2A = 'GPIO11';
var Motor2B = 'GPIO9';
var Motor2E = 'GPIO10';
// Motor 1
board.pinMode(Motor1A, board.MODES.OUTPUT);
board.pinMode(Motor1B, board.MODES.OUTPUT);
board.pinMode(Motor1E, board.MODES.OUTPUT);
// Motor 2
board.pinMode(Motor2A, board.MODES.OUTPUT);
board.pinMode(Motor2B, board.MODES.OUTPUT);
board.pinMode(Motor2E, board.MODES.OUTPUT);
// Normalize and store in vars
var p16 = board.normalize(Motor1A);
var p18 = board.normalize(Motor1B);
var p22 = board.normalize(Motor1E);
var p23 = board.normalize(Motor2A);
var p21 = board.normalize(Motor2B);
var p19 = board.normalize(Motor2E);
// Set pin 7's output to logic high
board.pins[p16].value = board.HIGH;
board.pins[p18].value = board.LOW;
board.pins[p22].value = board.HIGH;
setTimeout(function(){
board.pins[p22].value = board.LOW;
return;
},2000)
// Read a pin value
// console.log(board.pins[board.normalize('P1-7')].value); // outputs "1"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.