Skip to content

Instantly share code, notes, and snippets.

@Resseguie
Resseguie / gist:8302903
Created January 7, 2014 17:24
Oversimplified method of sending ThingSpeak updates from Spark Core. (Not really recommended for real world use.) This connects and sends data successfully several times, but eventually something hangs and it stops updating.
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "THINGSPEAK_WRITE_KEY";
const unsigned int updateThingSpeakInterval = 30000;
// Variable Setup
unsigned long lastConnectionTime = 0;
// Initialize TCP Client
TCPClient client;
@Resseguie
Resseguie / gist:8294929
Created January 7, 2014 05:19
Attempting to send analog data from Spark Core to Thingspeak. (Note: Something still not fully working. First post works, then it hangs.)
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "THINGSPEAK_WRITE_API";
const unsigned int updateThingSpeakInterval = 30000;
unsigned long lastConnectionTime = 0;
bool lastConnected = false;
int failedCounter = 0;
TCPClient client;
#!/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