Created
June 10, 2014 03:12
-
-
Save Resseguie/39b0b52a89dd24de1516 to your computer and use it in GitHub Desktop.
Simple scale based on J5 piezo API
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 five = require("../lib/johnny-five.js"), | |
board = new five.Board(); | |
board.on("ready", function() { | |
// Creates a piezo object and defines the pin to be used for the signal | |
var piezo = new five.Piezo(process.argv[2] || 3); | |
// Injects the piezo into the repl | |
board.repl.inject({ | |
piezo: piezo | |
}); | |
// Plays a song | |
piezo.play({ | |
// song is composed by an array of pairs of notes and beats | |
// The first argument is the note (null means "no note") | |
// The second argument is the length of time (beat) of the note (or non-note) | |
song: [ | |
["C4", 1], | |
["D4", 1], | |
["E4", 1], | |
["F4", 1], | |
["G4", 1], | |
["A4", 1], | |
["B4", 1], | |
["C5", 1], | |
["D5", 1], | |
["E5", 1], | |
["F5", 1], | |
["G5", 1], | |
["A5", 1], | |
["B5", 1], | |
["C6", 1] | |
], | |
tempo: 250 | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment