Skip to content

Instantly share code, notes, and snippets.

View caseyanderson's full-sized avatar

Casey Anderson caseyanderson

View GitHub Profile
@caseyanderson
caseyanderson / analogDigital.py
Created April 4, 2023 00:01
analogDigital.py
'''
analogDigital.py
'''
from machine import ADC, Pin, PWM
from time import sleep_ms
led1Pin = Pin(27)
led2Pin = Pin(33, Pin.OUT)
adcPin = Pin(34)
@caseyanderson
caseyanderson / keyTrigRec.scd
Last active February 3, 2023 21:48
keyDownAction triggers a Phasor until a keyUpAction, can be used to store and share the duration of a recording into a buffer. Note: repeat triggers from keyDownAction are blocked
s.options.inDevice_("MacBook Pro Microphone");
s.options.outDevice_("MacBook Pro Speakers");
s.boot;
~buf = Buffer.alloc( s, s.sampleRate * 60, 1);
~dur = Bus.control(s, 1);
(
SynthDef(\record, {|amp = 0.9, buf, rate = 1, recManualBus, off = 0, trig = 0|

Loop a Video 4evr

Casey Anderson, 2022

Note OMXPlayer is being "phased out" in favor of VLC, this tutorial assumes usage of Raspbian Buster Lite (Legacy), under which OMXPlayer is still available via aptitude

pre-flight

@caseyanderson
caseyanderson / displayIP-OLED-128x32.py
Last active October 17, 2022 18:49
Display RPi IP address on Adafruit's i2c Pi OLED (128x32) screen via python 3 subprocess (hostname -I). If MAC address is present in hostname output (no idea why this happens BTW) split by space and only pass IP to screen. Note: this file is written by Adafruit unless denoted otherwise.
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This demo will fill the screen with white, draw a black box on top
and then print Hello World! in the center of the display
This example is for use on (Linux) computers that are using CPython with
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
not support PIL/pillow (python imaging library)!

1. Orientation

p5.js is a JavaScript library created to establish computer literacy in visual arts applications. It abstracts the more complex components of JavaScript to provide a friendlier environment for experimentation.

Integrated Development Environment (IDE)

An Integrated Development Environment, or IDE, is a workspace for prototyping and developing code. p5.js has a browser-based IDE which we will use today, but you may want to look into using p5.js with VSCode or another ID. You can the browser-based one here.

Miniconda

Installation

  1. Go here to download the Miniconda 3 Installer for your operating system
  2. Once the download has finished run the installer:
    • MacOS: In the Terminal bash Downloads/Miniconda3-latest-MacOSX-x86_64.sh
    • Windows: Navigate to Downloads (or wherever you downloaded this) and double click the .exe file
  3. Follow the installation prompts
  4. Update Miniconda3:
    • MacOS: In the Terminal conda update conda
  • Windows: In Anaconda Powershell Prompt (miniconda3) execute conda update conda

Introduction to Python

Python is a general-purpose, interpreted, high-level programming language. The syntax of the language has been optimized to emphasize code readability, as well as brevity.

Note: though there are multiple versions of python we will exclusively use Python3

Variables & Strings

A variable is a container for data

Materials

  • laptop
  • internet access
  • Raspberry Pi
  • USB cable
  • microSD card
  • SD card reader

Write OS .img to SD card

The Command Line

Materials

MacOS

  • Laptop
  • Terminal

Windows 10

  • Laptop
  • Anaconda Powershell
'''
button_mode.py
'''
from machine import Pin
from time import sleep
button = Pin(12, Pin.IN, Pin.PULL_UP)
mode = 0