Created
January 4, 2015 02:01
-
-
Save motiooon/99148367b307d17cc08d to your computer and use it in GitHub Desktop.
raspi-io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var raspi = require('raspi-io'); | |
var five = require('johnny-five'); | |
var board = new five.Board({ | |
io: 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'; | |
// 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); | |
// 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) | |
// 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