Skip to content

Instantly share code, notes, and snippets.

@rxseger
rxseger / (clock)gpshiftreg.py
Last active December 26, 2016 20:28
script for 4x7-segment LED display as a digital clock using two 74HCT595 8-bit shift registers connected to Raspberry Pi
#!/usr/bin/python
# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
import time
import types
GPIO.setmode(GPIO.BOARD)
CLOCK = 36 # G16
@rxseger
rxseger / gpshiftreg.py
Created December 18, 2016 20:59
drive a 4-bit shift register via GPIO (2 outputs) on Raspberry Pi
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
CLOCK = 36 # G16
DATA = 7 # G4
@rxseger
rxseger / gpshiftreg
Created December 18, 2016 20:57
/etc/init.d/gpshiftreg startup script
#!/bin/sh
### BEGIN INIT INFO
# Provides: gpshiftreg
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Clocks in data to a shift register over GPIO
# Description: Turns on and off the segments a 4-digit 7-segment display salvaged from a microwave
### END INIT INFO
@rxseger
rxseger / config.json
Created November 1, 2016 03:09
~/.homebridge/config.json example for homebridge-udp-contactsensor
{
"accessory": "UdpContactSensor",
"name": "UDP Contact Sensors",
"listen_port": 8266,
"data": {
"Switch #2": { "on": "02ff", "off": "0200" },
"Switch #3": { "on": "03ff", "off": "0300" },
"Switch #4": { "on": "04ff", "off": "0400" }
}
@rxseger
rxseger / config.json
Last active October 31, 2016 03:44
~/.homebridge/config.json for homebridge-http to ESP8266 web server
{
"accessory": "Http",
"name": "Stand Lamp",
"http_method": "GET",
"on_url": "http://192.168.1.4/outlet/on",
"off_url": "http://192.168.1.4/outlet/off",
"service": "Light"
},
{
"accessory": "Http",
@rxseger
rxseger / gpdot.py
Created October 13, 2016 05:56
blink LED
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
DOT = 36 # G16
GPIO.setwarnings(False)
@rxseger
rxseger / motion.conf
Created October 9, 2016 21:37
~/.motion/motion.conf example configuration for Raspberry Pi with Pi Camera v2
videodevice /dev/video0
stream_port 8081
stream_localhost off
despeckle EedDl
smart_mask_speed 0
webcontrol_localhost off
webcontrol_port 8082
rotate 180
height 2592
width 1944
@rxseger
rxseger / pwmtachfan.py
Created October 9, 2016 06:10
pulse-width modulating to control a PC fan speed
#!/usr/bin/python -u
# tachfan.py - read RPM from a PC fan tachometer wired to GPIO
#
# references:
# http://electronics.stackexchange.com/questions/8295/how-to-interpret-the-output-of-a-3-pin-computer-fan-speed-sensor
# http://www.formfactors.org/developer/specs/REV1_2_Public.pdf
import RPi.GPIO as GPIO
import time
import pigpio
@rxseger
rxseger / tachfan.py
Created October 9, 2016 04:53
read RPM from a PC fan tachometer wired to GPIO
#!/usr/bin/python -u
# tachfan.py - read RPM from a PC fan tachometer wired to GPIO
#
# references:
# http://electronics.stackexchange.com/questions/8295/how-to-interpret-the-output-of-a-3-pin-computer-fan-speed-sensor
# http://www.formfactors.org/developer/specs/REV1_2_Public.pdf
import RPi.GPIO as GPIO
import time
@rxseger
rxseger / readall-mcp-spi-adc.js
Last active October 6, 2016 04:54
read all 8-channels on MCP3304 for testing https://github.com/fivdi/mcp-spi-adc/pull/1
'use strict';
var mcpadc = require('../');
function readadc(channel, cb) {
var adc = mcpadc.openMcp3304(channel, {speedHz: 20000}, function (err) {
if (err) throw err;
adc.read(cb);
});