Skip to content

Instantly share code, notes, and snippets.

View samneggs's full-sized avatar

Sam samneggs

View GitHub Profile
@samneggs
samneggs / Centipede.py
Created June 28, 2023 14:31
Centipede game on PI Pico in MicroPython
# Centipede
import centi_splash
from lcd_1_8 import LCD_1inch8
import machine
from machine import Pin, PWM
from uctypes import addressof
from time import sleep, ticks_us, ticks_diff, ticks_ms
import gc, _thread, array
@samneggs
samneggs / LCD_3inch5.py
Created June 8, 2023 21:28
LCD 3.5 inch driver
from machine import Pin,SPI,PWM,mem32,freq
import framebuf
from time import sleep_ms, sleep_us, ticks_diff, ticks_us
from micropython import const,heap_lock
import ustruct,gc
from random import randint
from usys import exit
LCD_DC = const(8)
LCD_CS = const(9)
@samneggs
samneggs / breakout_3_5.py
Last active June 8, 2023 21:27
Breakout game on 3.5" display in MicroPython
from LCD_3inch5 import LCD_3inch5
import framebuf, gc, _thread
from micropython import const
from machine import Timer, UART, Pin
#constants
BRICK_WIDTH = const(20)
BRICK_HEIGHT = const(10)
BALL_SIZE = const(5)
BALL_X_START = const(390)
@samneggs
samneggs / starcastle.py
Created April 16, 2023 02:30
StarCastle game on Pi Pico in MicroPython
# Star Castle
from lcd_1_8 import LCD_1inch8
import machine
from machine import Pin, PWM
from uctypes import addressof
from time import sleep, ticks_us, ticks_diff, ticks_ms
import gc, _thread, array
from sys import exit
from micropython import const
from random import randint
@samneggs
samneggs / artillery.py
Created March 28, 2023 23:09
Artillery Game on Pi Pico in MicroPython
#Artillery
from lcd_1_8 import LCD_1inch8
import machine
from machine import Pin, PWM
from uctypes import addressof
from time import sleep, ticks_us, ticks_diff, ticks_ms
import gc, _thread, array
from sys import exit
from micropython import const
from random import randint
@samneggs
samneggs / hill_climb.py
Created March 28, 2023 23:06
Hill Climb Racer on Pi Pico in MicroPython
# Hill Climb
from lcd_1_8 import LCD_1inch8
import machine
from machine import Pin, PWM
from uctypes import addressof
from time import sleep, ticks_us, ticks_diff, ticks_ms
import gc, _thread, array, framebuf
from sys import exit
from micropython import const
from random import randint
@samneggs
samneggs / race_bots.py
Created February 26, 2023 21:48
Racing Bots on Pi Pico in MicroPython
# Race car bots
from machine import Pin,SPI,PWM,ADC, Timer, reset, soft_reset
import framebuf, gc
import time, array, _thread
from time import sleep, ticks_us, ticks_diff, ticks_ms
from lcd_1_8 import LCD_1inch8
from random import randint
from sys import exit
from math import sin,cos,pi, radians
@samneggs
samneggs / missile_command.py
Last active February 27, 2023 07:08
Missile Command game in MicroPython on Pi Pico
# Missile Command game
from machine import Pin,SPI,PWM,ADC, Timer, reset, soft_reset
import framebuf, gc
import time, array, _thread
from time import sleep, ticks_us, ticks_diff, ticks_ms
from lcd_1_8 import LCD_1inch8
from random import randint
from sys import exit
@samneggs
samneggs / pico_sieve.py
Created February 9, 2023 01:42
Pi Pico - Calculate first 1,000,000 primes in Assembly
# pico_sieve.py
# Raspberry Pi Pico - Sieve of Eratosthenes demo
# Calculate all the prime numbers within a range of low integers.
# Based on:
#https://courses.ideate.cmu.edu/16-223/f2022/text/code/pico-numerical.html
import time,array
import math,gc
from usys import exit
@samneggs
samneggs / defender.py
Created January 30, 2023 04:35
Defender game on Pi Pico in MicroPython
from LCD_1inch14 import LCD_1inch14
from machine import Pin,SPI,PWM, Timer
import framebuf, math
import utime, gc
from random import randint
from usys import exit
from micropython import const
class Obj():
def __init__(self,x,y,ax,ay,w,h):