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 / espnow_simple_hacky_receiver.py
Last active May 28, 2026 20:58
Simple demo of ESPnow broadcast function on CircuitPython
# espnow-simple_hacky_receiver.py -- show ESPnow working broadcast on CircuitPython
# 9 Jul 2025 - @todbot
# tested on QTPY ESP32-S2 and FunHouse (ESP32-S2)
import time
import wifi
import espnow
# https://github.com/adafruit/circuitpython/issues/9380#issuecomment-2463013607
# hack to switch channel that is used for ESPNow
# this takes just a few milliseconds, so doesn't waste a lot of power
@todbot
todbot / code.py
Created May 25, 2026 20:54
USB HID Keyboard LED emulator in CircuitPython
import time
import usb_hid
import adafruit_hid
keyboard_hid = adafruit_hid.find_device(usb_hid.devices, usage_page=1, usage=6)
print("waiting for LED commands from computer")
while True:
out_report = keyboard_hid.get_last_received_report() # out from computer
if out_report:
@todbot
todbot / analog_buttons.py
Last active April 24, 2026 17:04
Use ADC and resistors to give you multiple buttons on single analog pin, for CircuitPython
# AnalogButtons - use ADC to give you multiple buttons
# 29 Jul 2025 - @todbot / Tod Kurt
# from an issue https://github.com/adafruit/circuitpython/issues/105272
# wiring is similar to https://www.instructables.com/How-to-Multiple-Buttons-on-1-Analog-Pin-Arduino-Tu/
import time
import board
import analogio
from collections import namedtuple
@todbot
todbot / derpnote2-rp2350.py
Created August 15, 2024 00:20
My sound piece attempting to recreate the THX "Deep Note" sound, with display
# derpnote2-rp2350.py - My sound piece attempting to recreate the THX "Deep Note" sound, with display
# 14 Aug 2024 - @todbot / Tod Kurt
#
import asyncio
import board, audiopwmio, audiomixer, audiocore, synthio, random, time
import busio, displayio, terminalio, vectorio
import keypad
import neopixel
import adafruit_displayio_ssd1306
from adafruit_display_text import bitmap_label as label
@todbot
todbot / podcast-clipper.sh
Last active March 5, 2026 23:05
Create a small video clip (for social sharing) of a larger podcast video hosted on Youtube
#!/bin/bash
#
# Create a small video clip of a podcast-like video on youtube.
# 4 March 2026 - Tod Kurt / @todbot
#
# This script does the following:
# - Download the video of the podcast
# - Download the subtitles of the podcast video
# - Create a copy of the entire video with the captions burned in
# - Snip the specified section of that video with audio waveform overlay
@todbot
todbot / wavetable_render_code.py
Last active March 5, 2026 10:01
Render wavetables for synthio to PyGamer display in CircuitPython
# wavetable_render_code.py - Render wavetables to PyGamer display
#
# 27 Aug 2023 - @todbot / Tod Kurt
#
# This code is currently a mess but it does function. :)
# video demo: https://www.youtube.com/watch?v=O9iZOytzOHg
#
# Needs wavetables in WAV format from http://waveeditonline.com/
# loaded in the "/wav" directory. Just download a few and stash them in "/wav"
#
@todbot
todbot / lilygo_tdisplay_s3_handsetup.py
Created March 28, 2024 20:18
LilyGo T-Display S3 display hand-setup in CircuitPython
"""
LilyGo T-Display S3 display hand-setup. Not normally required if using https://circuitpython.org/board/lilygo_tdisplay_s3/
"""
import time
import board
import digitalio
import displayio
import paralleldisplaybus
import adafruit_st7789
@todbot
todbot / synthio_midi_synth.py
Last active December 27, 2025 05:31
pretty usable MIDI-controlled synth using synthio in CircuitPython
# synthio_midi_synth.py - pretty usable MIDI-controlled synth using synthio in CircuitPython
# 11 May 2023 - @todbot / Tod Kurt
# Uses cheapie PCM5102 DAC on QTPY RP2040
# Video demo: https://www.youtube.com/watch?v=N-PbbWWDE6k
# Features:
# - midi velocity controls attack rate (gentle press = slow, hard press = fast)
# - notes have small random detune on all oscillators to reduce phase stacking
# - adjustable number of detuned oscillators per note 1-5 (midi controller 83)
# - five selectable waveforms: saw, squ, sin, noisy sin, noise (midi controller 82)
# - vibrato depth on mod wheel (midi controller 1)
@todbot
todbot / xiao_esp32c6_blink_button.ino
Last active September 24, 2025 23:07
Arduino code to read a button & blink a normal LED and a Neopixel on XIAO ESP32C6 w/ Adafruit Button BFF