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 / 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
@todbot
todbot / as1115_test.ino
Created November 8, 2024 22:55
simple AS1115 LED driver demo, for the Supercon "petal" SAO, in Arduino
// as1115_test.ino -- simple AS1115 LED driver demo, for the Supercon "petal" SAO
// 1 Nov 2024 - @todbot / Tod Kurt
// written for arduino-pico Arduino core, but should be usable for others
#include <Wire.h>
// simple class for dealing with AS1115 LED driver chip:
// https://ams-osram.com/products/drivers/led-drivers/ams-as1115-led-driver-ic
class AS1115_test {
public:
@todbot
todbot / touchio_debug_code.py
Created October 15, 2024 22:37
Debug raw touchio values in CircuitPython
# touchio_debug_code.py -- debug raw touchio values
# 15 Oct 2024 - @todbot / Tod Kurt
# This sketch shows the raw_value and threshold value for each
# touchio TouchIn input, as well as the normal ".value" boolean
# Hopefully this will help to debug touchio circuits.
import time
import board
import touchio
@todbot
todbot / synthy-balls.py
Last active October 4, 2024 13:27
use rotary encoder to launch balls that play notes when bouncing in CircuitPython
# synthy-balls.py -- use rotary encoder to launch balls that play notes when bouncing
# 20 Aug 2024 - @todbot / Tod Kurt
# video demo: https://youtu.be/cCTPtk6KQQk
import time, random, math
import board
import busio, displayio, terminalio
import rotaryio, keypad
import audiobusio, audiocore, audiomixer, synthio
import gc9a01
#from adafruit_display_text import bitmap_label as label
@todbot
todbot / mp3-cycler.py
Last active November 15, 2024 03:55
Play high-quality MP3s on RP2350 Tiny 2350 using the MacroPadSynthPlug as audio interface
# mp3-cycler.py -- Play high-quality MP3s on RP2350 Tiny 2350
# using the MacroPadSynthPlug as audio interface
# 15 Aug 2024 - @todbot / Tod Kurt
import time, os, random
import board
import audiocore, audiopwmio, audiomixer, audiomp3
import busio
import keypad
import rainbowio
@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 / random-boops.py
Created August 14, 2024 21:21
demo CircuitPython synthio on SparkFun Pro Micro RP2350
# random-boops.py - demo CircuitPython synthio on SparkFun Pro Micro RP2350
# 13 Aug 2024 - @todbot
#
import board, audiopwmio, audiomixer, audiocore, synthio, random, time
import neopixel
audio = audiopwmio.PWMAudioOut(board.D9)
synth = synthio.Synthesizer(sample_rate=22050)
audio.play(synth)
synth.envelope = synthio.Envelope(sustain_level=0.8, release_time=0.1, attack_time=0.001)
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)
@todbot
todbot / bouncy_jpheads.py
Created July 30, 2024 20:00
Bouncy John Park heads in CircuitPython
# bouncy_jpheads.py - use displayio to make simple bounch balls
# orignally from: https://gist.github.com/todbot/6f082f452806fad9cd4702c2f1b0aed4
# 30 Jul 2024 - @todbot
import time, random
import board, displayio, terminalio
from adafruit_display_text import label
import adafruit_imageload
display = board.DISPLAY # CP already sets up display for us, 240x135 for LILYGO T8 ESP32-S2
screen = displayio.Group() # a main group that holds everything