Created
October 24, 2012 21:31
-
-
Save No9/3949035 to your computer and use it in GitHub Desktop.
Motor Shield Johnny-Five Sketch
This file contains hidden or 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 five = require("johnny-five"), | |
// or "./lib/johnny-five" when running from the source | |
board = new five.Board(); | |
board.on("ready", function() { | |
var MOTOR1 = 12; | |
var MOTOR2 = 13; | |
var BREAK1 = 9; | |
var BREAK2 = 8; | |
var SPEEDPIN1 = 3; | |
var SPEEDPIN2 = 11; | |
var OUTPUT = this.firmata.MODES.OUTPUT; | |
var ANALOG = this.firmata.MODES.ANALOG; | |
var PWM = this.firmata.MODES.PWM; | |
var LOW = this.firmata.LOW; | |
var HIGH = this.firmata.HIGH; | |
this.pinMode( MOTOR2, OUTPUT ); | |
this.pinMode( BREAK2, OUTPUT ); | |
this.pinMode( SPEEDPIN2, PWM ); | |
//this.firmata.pinMode( SPEED, PWM ); | |
this.digitalWrite(MOTOR2, HIGH ); //Establishes backward direction of Channel A | |
this.digitalWrite(BREAK2, LOW ); //Disengage the Brake for Channel A# | |
this.analogWrite(SPEEDPIN2, 255); //Spins the motor on Channel A at half speed | |
this.wait( 2000, function() { | |
this.emit("wait complete") | |
//this.stop(); | |
///this.firmata.analogWrite( SPEED, 0 ); | |
this.digitalWrite(BREAK2, HIGH ); | |
}); | |
///this.digitalWrite(BREAK1, HIGH ); //Disengage the Brake for Channel A | |
//this.firmata.Delay(3000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment