Skip to content

Instantly share code, notes, and snippets.

View wFwd.ino
// w for Fwd
// A simple Teensy based USB keyboard that associats some kind of
// physical motion event to a 'w' press. This can be used to advance Google StreetView
// for an interactive exercise experience (Example here:
// Must select the "SERIAL+KEYBOARD..." mode under "USB TYPE" for the Teensy!
// This version uses a Sharp IR sensor (or equivalent), connected to A9 pin of a Teensy 3.2
johnty /
Last active Jul 30, 2021
scratchpad for sheets
from __future__ import print_function
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from datetime import datetime
from random import randint
from time import sleep
from sds011 import SDS011
johnty /
Created Jul 26, 2021
simple code to poll two SDS011 sensors connected via CH340G USB adapters
from sds011 import SDS011
from datetime import datetime
import time
#CH340G adapters seem to give port names
#based on which port you plug them into:
s1 = SDS011("/dev/tty.wchusbserial1410") #Left USB Port
s2 = SDS011("/dev/tty.wchusbserial1420") #Right USB Port
def read_sensor():
johnty / bellow.scad
Last active May 6, 2021
parametric bellow, designed to be printed in TPU for single dosing espresso grinders
View bellow.scad
//Parametric Bellow designed for blowing out grinds in an espresso grinder
// Designed to be printed using TPU
// Tested on Ender 3 Pro (2019) with stock extruder and 91A TPU from
// 15mm all speeds 2mm retraction @ 15mm/s. 75C bed 230/227C extruder temps
// 3 shell perimeter
// May 2021, Released under CC BY-SA 2.0 (
johnty / UDP-recorder.maxpat
Created Mar 18, 2021
Records UDP (OSC) messages with millisecond timestamps
View UDP-recorder.maxpat
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "Autosave and query of current file size",
"linecount" : 2,
"numoutlets" : 0,
"id" : "obj-38",
"patching_rect" : [ 568.0, 191.5, 150.0, 34.0 ],
"style" : "",
johnty /
Last active Jan 8, 2021
grabbing temperature (in F) from wifi thermocouple probe
import urllib.request #talks to an ESP32 running this code:
contents = urllib.request.urlopen("").read().decode() #find IP address and put it here...
f_string = contents.split("/")[2] #first / is for </head>, second / is between the C and F readings ;)
f_vals = f_string.split(); # split again based on spaces, result should be the F value string only.
johnty / midiPacket.ino
Last active Oct 15, 2020
CC MIDI packet with running status
View midiPacket.ino
uint8_t midiPacket[15] = {
0b10000000,  // header
0b10000000,  // timestamp, not implemented
0b00000000,  // status byte
midi.mapMIDI(abs(imu.getAccelX()), 0, 50));// CC 021 (0b00010101) (for X-axis accelerometer)
midi.mapMIDI(abs(imu.getAccelY()), 0, 50));// CC 022 (0b00010110) (for Y-axis accelerometer)
midi.mapMIDI(abs(imu.getAccelZ()), 0, 50));// CC 023 (0b00010111) (for Z-axis accelerometer)
johnty /
Last active Aug 1, 2020
grabbing esp32 bbq temp and outputting to file
while :
echo update at $(date)
echo `date` >> logdata.txt
curl -m 10 -s | cut -d'/' -f3 | cut -d'<' -f1 >> logdata.txt
sleep 60
johnty / mapperdirect.cs
Created Dec 20, 2019
rough libmapper C# example using direct C interface calls
View mapperdirect.cs
using System;
using System.Threading;
using System.Runtime.InteropServices;
public class HelloWorld
//public static extern int add(int a, int b);
[DllImport("mapper", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
johnty / latency_measure_trigger_test.ino
Last active Dec 2, 2019
test trigger for latency rig
View latency_measure_trigger_test.ino
//Trigger tester:
// use with eso32 lolin d32 pro, but can be adapted for any other
// emits T0 for pin 12
// emits T1 for pin 13 at slightly increasing delays of 100ms
// emits T2 for pin 14 at slightly decreasing delays of 100ms
#define PIN_T0 12
#define PIN_T1 13