Skip to content

Instantly share code, notes, and snippets.

View lesp's full-sized avatar
🏠
Working from home

Les lesp

🏠
Working from home
View GitHub Profile
@lesp
lesp / code.py
Created May 31, 2019 11:00
PyPortal Digital Conference Badge
import time
import board
from adafruit_pyportal import PyPortal
from adafruit_button import Button
from adafruit_slideshow import PlayBackOrder, SlideShow, PlayBackDirection
# Set the background color
BACKGROUND_COLOR = 0x000000
# Setup PyPortal without networking
@lesp
lesp / signature_count.py
Last active March 21, 2019 12:37 — forked from bennuttall/signature_count.py
petition watcher
import requests
from time import sleep
url = "https://petition.parliament.uk/petitions/241584/count.json"
def get_count():
count = None
while True:
r = requests.get(url)
if r:
@lesp
lesp / code.py
Created June 7, 2018 08:42
code.py from Gemma M0, code waits for button press to print FIRE in the REPL
# CircuitPython IO demo #1 - General Purpose I/O
import time
import board
from digitalio import DigitalInOut, Direction, Pull
switch = DigitalInOut(board.D2)
import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 30
WAVE_OUTPUT_FILENAME = "file.wav"
@lesp
lesp / find-file.py
Created June 29, 2017 19:54
Find mp3s, or anything else in a directory
import os
files = os.listdir("/directory/with/files/in")
print(list(filter(lambda x: 'mp3' in x, files)))
# For more options and information see
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
@lesp
lesp / serial-test.py
Created March 11, 2017 16:05
Code to interact with the serial
import serial, time
#Change the port to match the port that you will be using, Windows uses COM3 etc
port = "/dev/ttyACM0"
baud = 115200
while True:
s = serial.Serial(port)
s.baudrate = baud
s.parity = serial.PARITY_NONE
@lesp
lesp / ryan_oldcode.py
Created November 9, 2016 19:05
Old version of the code
import time
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23 , GPIO.IN)
while True:
counter = 0
@lesp
lesp / Ryan.py
Last active November 9, 2016 16:51
Take 20 pics using Picamera
from gpiozero import Button
from picamera import PiCamera
from datetime import datetime
from signal import pause
button = Button(18, pull_up=False)
camera = PiCamera()
def capture():
datetime = datetime.now().isoformat()
@lesp
lesp / GPIOZERO-test.py
Created June 2, 2016 14:21
Using GPIO Zero to flash an LED
from gpiozero import LED
from signal import pause
red = LED(17)
red.blink()
pause()