Skip to content

Instantly share code, notes, and snippets.

// instructions:
// 1.) install node.js and npm
// 2.) put this file in a folder
// 3.) go to this folder in terminal, and install ffi and ref using 'npm install ...'
// 4.) execute by typing `node node-ffi-mapper.js`
//
// note: refers explicitly to libmapper-0.2.dylib so make sure it is on the path!
var ref = require('ref');
var ffi = require('ffi');
@johnty
johnty / server.js
Last active August 22, 2016 13:35
sandbox
// Import Express
var express = require("express");
var app = express();
// Import Cors: cross origin resource
var cors = require("cors");
app.use(cors());
// Import Mongoose
var mongoose = require("mongoose");
@johnty
johnty / pigstest_servo
Created November 25, 2016 20:34
pigs servo test code
MAX=1700
MID=1500
MIN=1200
sudo pigpiod
pigs pfs 18 50 # set pwm freq to 50 hz on BCM18
pigs servo 18 $MID # set servo pulsewidth to MID us on BCM18
sleep 1
pigs servo 18 $MIN # set servo pulsewidth to MIN on BCM18
@johnty
johnty / PiPeopleCounter.json
Created December 22, 2016 21:21
pishield node-red people counter + photo taking
[{"id":"acc6e5cd.bbc508","type":"mcp3008","z":"54a3f28b.3cfa8c","name":"IR Sensor (CH7)","device":"/dev/spidev0.0","mode":"0xF0","interval":"50","x":296.5,"y":59,"wires":[["8497b430.1c4d18"]]},{"id":"f746b842.a8ddf8","type":"inject","z":"54a3f28b.3cfa8c","name":"","topic":"","payload":"start","payloadType":"str","repeat":"","crontab":"","once":true,"x":104,"y":40,"wires":[["acc6e5cd.bbc508"]]},{"id":"e4035cf3.8252d","type":"inject","z":"54a3f28b.3cfa8c","name":"","topic":"","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"x":104.5,"y":76,"wires":[["acc6e5cd.bbc508"]]},{"id":"89defb3b.aa7a88","type":"debug","z":"54a3f28b.3cfa8c","name":"","active":true,"console":"false","complete":"payload","x":605.5,"y":167,"wires":[]},{"id":"8497b430.1c4d18","type":"switch","z":"54a3f28b.3cfa8c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"200","vt":"num"},{"t":"lte","v":"199","vt":"num"}],"checkall":"true","outputs":2,"x":146.5,"y":174,"wires":[["9c4d90ba.a4173"],["c
@johnty
johnty / PiShield.m
Created April 6, 2017 18:00
Wolfram Connected Device Driver for PiShield A2D (MCP3008), using wiringpi GPIO command
(* until we figure out how to pass strings to ext commands, this bit is hard coded *)
readsensor[_, x_] :=
(<<"!gpio -x mcp3004:100:0 aread 100")
readsensor[_, 0] :=
(<<"!gpio -x mcp3004:100:0 aread 100")
readsensor[_, 1] :=
(<<"!gpio -x mcp3004:100:0 aread 101")
@johnty
johnty / PiPlant.json
Created April 18, 2017 17:42
PiPlant flow
[
{
"id":"1b6d4b38.cc6c95",
"type":"tab",
"label":"PiPlant"
},
{
"id":"7e18a8a7.dea448",
"type":"rpi-gpio out",
"z":"1b6d4b38.cc6c95",
@johnty
johnty / PiPlant_gauge.json
Created April 25, 2017 21:44
PiPlant flow with FRED integration and servo driver for physical gauge
[
{
"id":"7e18a8a7.dea448",
"type":"rpi-gpio out",
"z":"1b6d4b38.cc6c95",
"name":"Relay 1",
"pin":"13",
"set":true,
"level":"0",
"out":"out",
@johnty
johnty / node-red-keyboard
Created April 25, 2017 22:20
play a midi keyboard with node-red
[
{
"id":"106236e9.a79359",
"type":"ui_button",
"z":"c7976967.e6bb98",
"name":"",
"group":"134bfa7c.f58646",
"order":1,
"width":0,
"height":0,
@johnty
johnty / PySeqControl.json
Created May 18, 2017 17:56
pysequencer control node-red flow. requires node-red-contrib-osc
[
{
"id":"67e93ae6.080164",
"type":"tab",
"label":"PySeqControl"
},
{
"id":"ff38aa39.6692d8",
"type":"osc",
"z":"67e93ae6.080164",
@johnty
johnty / MoistureMusicMap.json
Last active May 30, 2017 19:40
maps single moisture value (0-100) to tempo and key variables of a simple algorithmic sequencer
[
{
"id":"98459436.cfd5b8",
"type":"ui_slider",
"z":"185b40f6.0c777f",
"name":"",
"label":"moisture level",
"group":"e97b599c.1d6968",
"order":1,
"width":"5",