Skip to content

Instantly share code, notes, and snippets.

@Resseguie
Created June 10, 2014 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Resseguie/39b0b52a89dd24de1516 to your computer and use it in GitHub Desktop.
Save Resseguie/39b0b52a89dd24de1516 to your computer and use it in GitHub Desktop.
Simple scale based on J5 piezo API
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