Skip to content

Instantly share code, notes, and snippets.

View softweyr's full-sized avatar

Wes Peters softweyr

View GitHub Profile
@softweyr
softweyr / code.py
Created July 14, 2025 05:37
Read AS5600 magnetic position sensor with Raspberry Pi Pico and CircuitPython
# AS5600 experiment on Raspberry Pi Pico (W, not that it makes any difference)
#
# A simple 3D printed test jig to explore the AS5600 is available at
# https://www.thingiverse.com/thing:7091000
# Import necessary libraries for CircuitPython
import time
import board
import busio
import adafruit_as5600
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""Simpletest Example that shows how to get temperature,
pressure, and altitude readings from a bme680"""
import time
import board
# import digitalio # For use with SPI
import busio
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # output from PIR motion sensor
def motion(channel):
print("Sensed motion")
GPIO.add_event_detect(11, GPIO.RISING, callback=motion, bouncetime=300)
@softweyr
softweyr / (app)__init__.py
Created February 6, 2020 06:04
A simple Flask app to blink an LED on Raspberry Pi.
from flask import Flask
app = Flask(__name__)
from app import routes
/**
* Copyright © 2020 Wesley Peters
* License: Creative Commons Attribution Non-Commercial License V2.0
* License details are available at https://creativecommons.org/licenses/by-nc/2.0/
*/
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
# Copyright © 2020 Wesley Peters
# License: Creative Commons Attribution Non-Commercial License V2.0
# License details are available at https://creativecommons.org/licenses/by-nc/2.0/
from gpiozero import LED
from time import sleep
def cpuTemp():
cpuTemp.sf.seek(0, 0)
@softweyr
softweyr / login.py
Created November 29, 2019 21:36
A super simple password GUI
import PySimpleGUI as sg
import hashlib
sg.change_look_and_feel('DarkAmber') # Add a touch of color
# All the stuff inside your window.
layout = [ [sg.Text('Username:'), sg.InputText()],
[sg.Text('Password'), sg.InputText()],
[sg.Button('Ok')] ]
canned_password = b"\x01~\xd8\x95\x0b\xd3\x1e*t\xfc\xac\x89\xa9\x1b\x9c&T\x1dc\x0b\xa7\xb2<'\x18\x1c\xe2\xfd_Jm\x92"
@softweyr
softweyr / dacled.py
Created June 6, 2018 01:17
Tickle an MCP23S17 DIO Expander on SPI 0,0 and an MCP4901 DAC on SPI 0,1
#! /usr/bin/python
#
# Tickle an MCP23S17 DIO Expander on SPI 0,0
# and an MCP4901 DAC on SPI 0,1
import spidev
import sys
import time
# MCP23S17 register addresses
// User-modifiable parts
const int sampleRate = 500; // microseconds
#define nSamples 100000
// End of user-modifiable parts!
const int inputPin = A0;
const int outputPin = A22;
#! /bin/sh
# "Mood Hat" for Raspberry Pi with Sense Hat
#
# Display a sort of graphical state of the system on the Sense Hat
#
while true
do
ps axleww | openssl sha512 > /dev/fb1
sleep 1
done