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: https://www.instagram.com/p/CF-xVWgJiFK/)
//
// 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
johnty / quickstart.py
Last active Jul 30, 2021
scratchpad for sheets
View quickstart.py
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
johnty / Dual_SDS011_test.py
Created Jul 26, 2021
simple code to poll two SDS011 sensors connected via CH340G USB adapters
View Dual_SDS011_test.py
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
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 filaments.ca
// 15mm all speeds 2mm retraction @ 15mm/s. 75C bed 230/227C extruder temps
// 3 shell perimeter
//
// johntywang@gmail.com
// May 2021, Released under CC BY-SA 2.0 (http://creativecommons.org/licenses/by-sa/2.0/)
echo(version=version());
@johnty
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
johnty / get_temp.py
Last active Jan 8, 2021
grabbing temperature (in F) from wifi thermocouple probe
View get_temp.py
import urllib.request #talks to an ESP32 running this code: https://github.com/johnty/BBQProbe/tree/main/thermocouple_esp32
contents = urllib.request.urlopen("http://192.168.1.65").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.
print(f_vals[0])
@johnty
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
21,
midi.mapMIDI(abs(imu.getAccelX()), 0, 50));// CC 021 (0b00010101) (for X-axis accelerometer)
22,
midi.mapMIDI(abs(imu.getAccelY()), 0, 50));// CC 022 (0b00010110) (for Y-axis accelerometer)
23,
midi.mapMIDI(abs(imu.getAccelZ()), 0, 50));// CC 023 (0b00010111) (for Z-axis accelerometer)
@johnty
johnty / bbq_log.sh
Last active Aug 1, 2020
grabbing esp32 bbq temp and outputting to file
View bbq_log.sh
while :
do
echo update at $(date)
echo `date` >> logdata.txt
curl -m 10 -s 192.168.1.96 | cut -d'/' -f3 | cut -d'<' -f1 >> logdata.txt
sleep 60
done
@johnty
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
{
//[DllImport("example")]
//public static extern int add(int a, int b);
[DllImport("mapper", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
@johnty
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