Skip to content

Instantly share code, notes, and snippets.

View seantibor's full-sized avatar

Sean Tibor seantibor

View GitHub Profile
@seantibor
seantibor / code.py
Created May 4, 2019 11:41
PyPortal conference badge for #PyCon2019
"""
This example will set up a simple conference badge with two different screens and a QR code.
"""
import time
import board
from adafruit_pyportal import PyPortal
import adafruit_touchscreen
# the current working directory (where this file is)
@seantibor
seantibor / infinite_generator_neopixel.py
Created May 31, 2019 15:12
uses the Adafruit wheel function and a generator to iterate back and forth over a range of colors.
from adafruit_circuitplayground.express import cpx
import time
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if pos < 0 or pos > 255:
return (0, 0, 0)
if pos < 85:
return (255 - pos * 3, pos * 3, 0)
@seantibor
seantibor / cpx_traffic_light.py
Created June 1, 2019 15:44
A traffic light using Adafruit Itertools
import neopixel
import time
import board
from adafruit_itertools.adafruit_itertools import cycle
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.1, auto_write=False)
RED = (255, 0, 0)
YELLOW = (255, 255, 0)
GREEN = (0, 255, 0)
@seantibor
seantibor / tasks.json
Created June 1, 2019 16:00
Copy to CircuitPython Device task for VS Code
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Copy to CircuitPython Device",
"type": "shell",
"command": "cp -f ${file} /Volumes/*PY/code.py",
"presentation": {
@seantibor
seantibor / gist:608186579b2683265d56aa457f7c4b91
Last active June 26, 2019 20:17 — forked from Jivemofo/gist:4d6525387b91a2e93755b353a9f1cf7a
Circuit Playground Express Led Button Test
# this program detects a button press and lights up a new Led, 2nd button changes colors
from adafruit_circuitplayground.express import cpx, time
cpx.pixels.brightness = 0.3
cpx.pixels.fill((0, 0, 0))
# pick how many colors to use
color_mode = 3
@seantibor
seantibor / gist:f6ca28987b419a701b6349055450939b
Last active June 26, 2019 20:41 — forked from Jivemofo/gist:a6403b1b5a8cbdc82eb403f54f6336f9
Circuit Playground Express Led Button Test
# this program detects a button press and lights up a new Led, 2nd button changes colors
from adafruit_circuitplayground.express import cpx, time
# pick how many colors to use
color_mode = 3
RED = (255, 0, 0)
GREEN = (0, 255, 0)
# A very simple Flask Hello World app for you to get started with...
from flask import Flask, render_template
import random
students = ['Alison','George', 'Jonah','Jake','Peter','Tyler','Savannah','Aviah','Taylor','Ellie','Shaun','Aiden']
app = Flask(__name__)
@seantibor
seantibor / minecraft_aquarium.py
Created February 7, 2020 15:47
Python Aquarium Code for MineCraft
def item_interacted_trident():
blocks.fill(SANDSTONE,
pos(5, -1, -10),
pos(12, -1, 10),
FillOperation.REPLACE)
blocks.fill(GLASS,
pos(5, 0, -10),
pos(12, 7, 10),
FillOperation.REPLACE)
blocks.fill(WATER, pos(6, 0, -9), pos(11, 7, 9), FillOperation.REPLACE)
# Write your code here :-)
# idea from this YouTube video: https://www.youtube.com/watch?v=kbKtFN71Lfs
import random
import turtle as t
def midpoint(point1, point2):
# given two coordinates, find the point halfway between them
x1, y1 = point1
x2, y2 = point2
@seantibor
seantibor / agent_mineshaft.py
Last active September 28, 2023 19:52
Code for Minecraft EDU Edition to dig a mineshaft with the agent. Works with Python notebooks and the code builder
directions = ("left","right","up", "down")
ignore_bricks = ['dirt','stone', "gravel", "air"]
def dig_inspect(direction):
"""Inspects for uncommon brick types and then digs them anyway"""
block = agent.inspect(direction)
while block not in ("air", "torch"):
if block not in ignore_bricks:
say(f"Found {block} to the {direction}. Destroying anyway")