Skip to content

Instantly share code, notes, and snippets.

View todbot's full-sized avatar
💭
doing the blink1

Tod Kurt todbot

💭
doing the blink1
View GitHub Profile
@todbot
todbot / pyplot_example.py
Created May 13, 2025 18:11
reminder to me about how to use pyplot and np.polyfit
import numpy as np
import matplotlib.pyplot as plt
# Original data points
x_vals = np.array([-0.5, -23.6, -58.3])
y_vals = np.array([1, 47, 110])
# Linear regression (best-fit line)
coeffs = np.polyfit(x_vals, y_vals, 1)
linear_fit = coeffs[0] * x_vals + coeffs[1]
@todbot
todbot / asyncio_led_demo.py
Created May 8, 2025 20:54
simple asyncio demo of two LEDs using global variables
# simple asyncio demo of two LEDs using global variables
# 8 May 2025 - @todbot
import asyncio
import board
import digitalio
ledA = digitalio.DigitalInOut(board.GP25)
ledB = digitalio.DigitalInOut(board.GP0)
ledA.switch_to_output(value=False)
ledB.switch_to_output(value=False)
@todbot
todbot / m7_frozen_midi_test.md
Last active May 6, 2025 23:21
Test how adding adafruit_midi as a frozen module impacts M7 RAM usage in CircuitPython

Summary:

  • CircuitPython 9.2.7 on Metro M7 and CIRCUITPY/lib adafruit_midi: 39.9 kB free -> 23.2 kB free
  • CircuitPython 10.0.alpha3 on Metro M7 and frozen adafruit_midi: 31.3 free -> 21.3 kB free

Using adafruit_midi in CIRCUITPY/lib installed with circup:

Adafruit CircuitPython 9.2.7 on 2025-04-01; Metro MIMXRT1011 with IMXRT1011DAE5A
>>> 
>>> import gc
@todbot
todbot / video_production_checklist.md
Last active January 1, 2025 23:42
Checklist for Tod when uploading content to Youtube & socials

Video Production Checklist

Create the footage

  • Record video / performance
  • Verify video framing is good
  • Verify audio is good (no clipping, no dropouts, stereo isn't wonky)
  • Re-record until good
  • Sync video file to Mac
  • Post-produce video (reframe, fix color grade, add hipster effects)
@todbot
todbot / many_neopixel_strips.ino
Created December 6, 2024 23:53
Show many neopixel strips in use simultaneously using Adafruit_NeoPixel
// Show many neopixel strips in use simultaneously using Adafruit_NeoPixel
//
// 2024Dec12 - @todbot
// compiles, not tested
#include <Adafruit_NeoPixel.h>
#define NUM_STRIPS 3
const int pin_for_strip[] = {A0, A2, 5};
@todbot
todbot / pico_sdk_setup.sh
Created November 27, 2024 20:22
# Pico-SDK setup and compile for Pico W as of 2024 Nov
# Pico-SDK setup and compile as of 2024 Nov
git clone https://github.com/raspberrypi/pico-sdk/
git clone https://github.com/raspberrypi/pico-examples
# set up the sdk
cd pico-sdk
export PICO_SDK_PATH=`pwd`
git submodule update --init
@todbot
todbot / two_pot_drone_synth.py
Last active December 27, 2024 00:08
Drone synthing using two knobs to control three voices in synthio with optional echo effect in CircuitPython
# two_pot_drone_synth.py -- Use two knobs to control three voices in synthio
# with optional echo effect
# 25 Nov 2024 - @todbot / Tod Kurt
# video demo: https://www.youtube.com/watch?v=xEmhk-dVXqQ
# original simpler version:
# https://gist.github.com/todbot/53bfa7333ac7c1fcff8eaf0f547556ff
import time, random
import board, keypad, analogio
import audiopwmio, audiomixer, synthio
@todbot
todbot / bouncy_balls_vectorio.py
Last active November 14, 2024 01:10
use displayio and vectorio to make simple bounch balls in CircuitPython
# bouncy_balls_vectorio.py - use displayio to make simple bounce balls
# 12 Nov 2024 - @todbot / Tod Kurt. Based off bouncy_balls1.py
import time, random
import board, busio, displayio, i2cdisplaybus
import vectorio
import adafruit_displayio_ssd1306
# configuration options
num_balls = 12
ball_size = 5
// touchwheelsao_test.ino -- test TouchwheelSAO in Arduino
// 5 Nov 2024 - @todbot / Tod Kurt
// assumes usuing arduino-pico arduino core
// tune the Wire setup to match your system
#include <Wire.h>
const int i2c_addr = 0x54;
//const int i2c_addr = 0x56; // tod's test wheel
@todbot
todbot / pico_i2c_test.ino
Last active November 9, 2024 18:53
Test pico-sdk i2c functions in Arduino, in this case reading TouchwheelSAO
// pico_i2c_test.ino -- test pico-sdk i2c functions in Arduino, in this case reading TouchwheelSAO
// 9 Nov 2024 - @todbot / Tod Kurt
// demo using pico-sdk i2c functions inside of Arduino sketch
// copies from https://github.com/raspberrypi/pico-examples/blob/master/i2c/lis3dh_i2c/lis3dh_i2c.c
// assumes compiling with arduino-pico Arduino core for Pico/PicoW
#include <Wire.h>
#define _i2c_dev i2c0
#define _clkHz 400000