Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env node
var Heroku = require('heroku-client');
var heroku = new Heroku({ token: process.env.HEROKU_API_TOKEN });
console.log('Restarting Dyno');
heroku.apps(process.env.APP_NAME).dynos().restartAll(function(err, res) {
console.log('done', err, res);
});

Servo PWM vs "Normal" PWM

This started from a chat in the [https://gitter.im/rwaldron/johnny-five](Johnny Five Gitter) and I thought I'd put some notes together because this comes up relatively often as people run into the terminology confusion that is caused by the Servo Manufacturers adopting the term PWM and it's usage amongst the Arduino community in relation to analogWrite().

This is my attempt at an explanation so if I've made any mistakes then please PR and we can make this better for everyone.

Servo is generally served by PWM support, right?

Sort of - PWM is typically a reference to an on/off duty cycle time - if I set my duty cycle to 50% then my pulses are on for 50% of the time and off for 50% of the time. If it's 10% then it's on 10% of the time, off 90%.

@Resseguie
Resseguie / gist:4c4a554eae159a819875
Created November 25, 2014 04:03
spark-io sensor example
var five = require("johnny-five"),
Spark = require("spark-io"),
board, sensor;
// Create Johnny-Five board connected via Spark
board = new five.Board({
io: new Spark({
token: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID
})
@Resseguie
Resseguie / say-all-voices.js
Created October 21, 2014 01:52
Iterates over all say.js voices
#!/usr/bin/env node
'use strict'
var say = require('say'),
toSay = process.argv[2] || "Hello World",
voices = [
"Agnes",
"Kathy",
"Princess",
@Resseguie
Resseguie / gist:e308663338f38ed7770c
Created September 15, 2014 03:41
RGB LED on then color
var five = require("johnny-five"),
Spark = require("spark-io"),
board = new five.Board({
io: new Spark({
token: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID
})
});
// The board's pins will not be accessible until
@Resseguie
Resseguie / rgb-on.js
Created September 15, 2014 02:20
Led.RGB.on doesn't save color state
var five = require("johnny-five");
new five.Board().on("ready", function() {
console.log("CONNECTED");
var led = new five.Led.RGB([3,5,6]);
led.on();
setTimeout(function() {
@Resseguie
Resseguie / gist:e9418f05d6db50f1c774
Created September 14, 2014 03:24
Spark-IO RGB LED with timeout
var five = require("johnny-five"),
Spark = require("spark-io"),
board = new five.Board({
io: new Spark({
token: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID
})
});
// The board's pins will not be accessible until
@Resseguie
Resseguie / gist:b8297d36dd41b320f29f
Last active August 29, 2015 14:06
Spark RGB LED
var five = require("johnny-five"),
Spark = require("spark-io"),
board = new five.Board({
io: new Spark({
token: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID
})
});
// The board's pins will not be accessible until
@Resseguie
Resseguie / joyToWorld.js
Created July 21, 2014 03:13
Joy to the World using J5 piezo. Crashes at "come" ( ["C4", 1] ) because it's missing a comma
var five = require('johnny-five');
five.Board().on('ready', function () {
var piezo = new five.Piezo();
var joyToWorld = {
song: [
["C5", 1],
["B4", 3/4],
["A4", 1/4],
@Resseguie
Resseguie / sparkio-temp.js
Last active August 29, 2015 14:02
voodoospark #23 using spark-io
var five = require("johnny-five"),
Spark = require("spark-io"),
board, sensor;
// Create Johnny-Five board connected via Spark
board = new five.Board({
io: new Spark({
token: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID
})