Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
var five = require("../lib/johnny-five.js");
var board = new five.Board();
function toMV(value) {
return five.Fn.map(value, 0, 1023, 0, 5000) | 0;
}
board.on("ready", function() {
var relay = new five.Relay(7);
var monitor = new five.Sensor("A0");
var $ = require('NodObjC');
$.import('Cocoa');
var installNSBundleHook = function() {
var cls = $.NSBundle;
if (cls) {
var bundleIdentifier = cls.getInstanceMethod('bundleIdentifier');
bundleIdentifier.setImplementation(function(val) {
@rwaldron
rwaldron / exponentiation.md
Last active August 29, 2015 14:01
Exponentiation Operator: **

Exponentiation Operator

Performs exponential calculation on operands. Same algorithm as Math.pow(x, y)

  • Commonly used in albegra, geometry, physics and robotics.
  • Nice to have "inline" operator

Prior Art

  • Python
var five = require("johnny-five");
var Spark = require("spark-io");
var keypress = require("keypress");
var board = new five.Board({
io: new Spark({
token: "{YOURS}",
deviceId: "{YOURS}"
})
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/* ServoTimer2.cpp*/
extern "C" {
// AVR LibC Includes
#include <inttypes.h>
#include <avr/interrupt.h>
#include "WConstants.h"
}
#include <wiring.h>
#include "ServoTimer2.h"
static void initISR();
@rwaldron
rwaldron / calibrate-servo.js
Last active August 29, 2015 14:02
Calibrating a continuous servo and external power warning
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
/*
Assuming a continuous servo is attached to pin 9,
this program can be called as:
node calibrate-servo.js
/* MAX7219 Interaction Code
* ---------------------------
* For more information see
* http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
*
* 668 bytes - ATmega168 - 16MHz
*/
// 16MHz clock
#define F_CPU 16000000UL
var serialport = require('node-serialport')
var sp = new serialport.SerialPort("/dev/ttyO3", {
parser: serialport.parsers.raw,
baud: 9600
})
sp.on('data', function(chunk) {
console.log(chunk.toString('hex'), chunk.toString(), chunk)
})