Skip to content

Instantly share code, notes, and snippets.

@todbot
todbot / staroids_code.py
Last active June 23, 2022 19:53
fakey Almost Asteroids in CircuitPython on FunHouse (ESP32-S2)
# staroids_code.py -- fakey Almost Asteroids
# 4 Aug 2021 - @todbot
# This is just a sketch, the full version of this idea is at https://github.com/todbot/circuitpython_staroids
import board, time, math, random
import displayio, terminalio, bitmaptools
import adafruit_imageload
import bitmaptools
import digitalio
button_L = digitalio.DigitalInOut(board.BUTTON_UP)
@todbot
todbot / random_notes_scale2.py
Last active July 26, 2021 23:32
play random melody in scale, w/ LEDS & LCD accompaniment (CircuitPython on Adafruit FunHouse) video: https://twitter.com/todbot/status/1416139823383941120
# random_notes_scale2.py - play random melody in scale, w/ LEDS & LCD accompaniment
# 16 Jul 2021 - @todbot
import time, random, math
import board, digitalio, pwmio
import adafruit_dotstar # or neopixel
import displayio, terminalio
from adafruit_display_text import label
leds = adafruit_dotstar.DotStar(board.DOTSTAR_CLOCK, board.DOTSTAR_DATA, 5, brightness=0.1)
mylabel = label.Label(terminalio.FONT, text="Music???", x=40,y=50, scale=4, color=0xff00ff)
display = board.DISPLAY
@elementc
elementc / code.py
Created May 16, 2021 22:22
serial byte read on keybow2040
import math
import board
from keybow2040 import Keybow2040, number_to_xy, hsv_to_rgb
import usb_cdc
# Some constants
FULLBRIGHT = 1
MINBRIGHT = 0.05
# Set up Keybow
# AMG8833 thermal camera on an ILI9341 320x240 screen
# Michael Horne, based on Jan Goolsbey's code for Adafruit
# https://learn.adafruit.com/pygamer-thermal-camera-amg8833?view=all
import time
import board
import displayio
import busio
from simpleio import map_range
from adafruit_display_text.label import Label
@dglaude
dglaude / code.py
Created March 8, 2021 23:16
Special gift for Michael Horne
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# Customised by David Glaude for Michael Horne
# Download the latest version of the IS31FL3731 library: https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731/archive/master.zip
# soon available from https://circuitpython.org/libraries in the "Bundle Version 6.x"
# Also take the adafruit_framebuf too from the library bundle
#
# Download the font font5x8.bin from https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin
@codepope
codepope / pimoroni rgb keypad for circuitpython
Created February 13, 2021 17:44
pimoroni rgb keypad for circuitpython - wip
mport board
import digitalio
import busio
import random
import time
class RGBKeyPad:
WIDTH=4
HEIGHT=4
NUMPADS=WIDTH*HEIGHT
@sandyjmacdonald
sandyjmacdonald / code.py
Created January 23, 2021 11:23
Emergency cat GIF macro example for Pimoroni RGB Keypad for Raspberry Pi Pico
import time
import board
import busio
import usb_hid
from adafruit_bus_device.i2c_device import I2CDevice
import adafruit_dotstar
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
@netroy
netroy / code.py
Last active December 12, 2021 06:36
circuitpython clock for Lilygo TTGO T8 ESP32-S2
import struct
import time
import board
import displayio
import rtc
import socketpool
import terminalio
import wifi
from adafruit_display_text import label
@jameseleach
jameseleach / code-deep-sleep.py
Last active January 16, 2021 18:32
Weather Station
# Time libraries
import rtc
import time
import alarm # for sleep and deep sleep
# Adafruit hts221 and supporting libraries
import board
import busio
import adafruit_hts221 # this library is dependent on adafruit_bus_device and adafruit_register
@shivasiddharth
shivasiddharth / nasmounter.sh
Last active November 15, 2023 23:42
Script to mount NAS in Linux
#!/bin/bash
set -o errexit
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
sudo apt-get install cifs-utils