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 / trinkey_theremin_pitch_code.py
Last active July 24, 2024 16:08
Trinkey MIDI Theremin with Pitch! (will also work on any other CircuitPython devices with `touchio`)
# trinkey_theremin_pitch_code.py -- Trinkey MIDI Theremin! with pitch control!
# 2021 @todbot
# left antenna: pitch (by multiple MIDI notes, put your synth in legato mode)
# right antenna: filter cutoff
# video demo in comment below
#
import time
import board
import neopixel
import touchio
@todbot
todbot / sleepy_keys.py
Last active July 11, 2024 18:19
Sleep a Windows box with CircuitPython using USB HID
# SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt
#
# SPDX-License-Identifier: MIT
"""
`sleepy_keys`
=============
HID System Control Powerdown / Sleep / Wake device helper library
* Author(s): Tod Kurt
@todbot
todbot / simple_midi_input_serial_pico.ino
Created July 9, 2024 15:26
Simple MIDI input using MIDI Library on Pico / RP2040 on Arduino
// Simple MIDI input using MIDI Library on Pico
// 2 Mar 2023 - @todbot / Tod Kurt
#include <MIDI.h>
// Serial MIDI, could be "Serial1" or "Serial2" depending on pins on Pico
// See: https://arduino-pico.readthedocs.io/en/latest/serial.html
// and https://pico.pinout.xyz/
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDIserial);
@todbot
todbot / MPSelectMiniV2-PrusaSlicer_config_bundle.ini
Created April 2, 2020 04:10
My attempt at a PrusaSlicer config bundle for Monoprice Select Mini V2. Import with "File" -> "Import..." -> "Import Config Bundle"
# generated by PrusaSlicer 2.2.0+ on 2020-04-02 at 04:02:32 UTC
[print:0.175mm - Monoprice Mini Select v2]
avoid_crossing_perimeters = 0
bottom_fill_pattern = rectilinear
bottom_solid_layers = 3
bottom_solid_min_thickness = 0
bridge_acceleration = 0
bridge_angle = 0
bridge_flow_ratio = 1
@todbot
todbot / rotaryio_demo_usb_keyboard_code.py
Last active June 26, 2024 17:57
Demonstrate rotaryio sending USB keyboard events in CircuitPython on RaspberryPiPico
# wire a rotary encoder to GP2,GP3, and encoder switch to GP4, with commons going to Gnd
import board
import rotaryio
import keypad
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
CLK_PIN = board.GP4
DT_PIN = board.GP3
@todbot
todbot / synthio_midi_synth.py
Last active June 23, 2024 08:27
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 / dual_i2s_player.py
Last active June 18, 2024 18:05
Demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico in CircuitPython
# dual_i2s_player.py -- demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico
# 19 May 2023 - @todbot / Tod Kurt
# video of this code: https://www.youtube.com/watch?v=CgqECxhqJEo
import time, board, audiocore, audiobusio
# qtpy rp2040 pins
# in this case, board.* names just match silkscreen, don't indicate functionality
lck1_pin, bck1_pin, dat1_pin = board.MISO, board.MOSI, board.SCK
lck2_pin, bck2_pin, dat2_pin = board.SCL, board.SDA, board.TX
@todbot
todbot / tinyusb_hid_ctrl_mousescroll.ino
Last active June 17, 2024 14:05
Use TinyUSB to emulate keyboard + mouse to press Ctrl key and do mouse scroll at the same time. Tested on QT Py M0
/*
tinyusb_hid_ctrl_mousesscroll.ino
2021 @todbot
Modified example from
https://github.com/adafruit/Adafruit_TinyUSB_Arduino/blob/master/examples/HID/hid_composite/hid_composite.ino
This sketch demonstrates multiple report USB HID.
Press button pin will move
- press 'Ctrl' key
- mouse scroll up using scrollwheel
@todbot
todbot / EZ_USB_MIDI_HOST_PIO_example_midisend.ino
Last active June 13, 2024 01:27
USB MIDI Host using PIO on RP2040 USB Type A Host Feather
/**
* Modified 12 Jun 2024 - @todbot -- added USB MIDI forwarding
* originally from: https://github.com/rppicomidi/EZ_USB_MIDI_HOST/blob/main/examples/arduino/EZ_USB_MIDI_HOST_PIO_example/EZ_USB_MIDI_HOST_PIO_example.ino
* Be sure to set "Tools / CPU Speed" to 120 MHz or 240 MHz and
* be sure to set "Tools / USB Stack" to "Adafruit TinyUSB"
*/
/*
* The MIT License (MIT)
*
@todbot
todbot / beatfader_demo.py
Last active June 12, 2024 23:11
fade between different drum loops on QTPy RP2040 or Xiao RP2040 in CircuitPython
"""
beatfader_demo.py -- fade between different drum loops
10 Jun 2024 - @todbot / Tod Kurt
originally from
https://github.com/todbot/circuitpython-tricks/blob/main/larger-tricks/beatfader.py
Demonstrate how to play WAVs via PWM audio
Functions, designed for QTPy RP2040 or Xiao RP2040: