This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"accessories": [ | |
{ | |
"accessory": "GPIO", | |
"name": "Desk Lamp", | |
"pin": 16 | |
}, | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import RPi.GPIO as GPIO | |
if len(sys.argv) < 2: | |
print 'usage: %s [0/1]' % (sys.argv[0],) | |
raise SystemExit | |
GPIO.setmode(GPIO.BOARD) | |
CONTROL = 16 # G23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# buzz.py - test magnetic transducer for nightlight | |
import time | |
import math | |
import pigpio | |
pi = pigpio.pi() # sudo pigpiod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# nightlight.py - toggle LED on Raspberry Pi GPIO on/off given MCP3304 ADC to OPT101 ambient light reading | |
# https://medium.com/@rxseger/spi-interfacing-experiments-eeproms-bus-pirate-adc-opt101-with-raspberry-pi-9c819511efea | |
import spidev | |
import time | |
import RPi.GPIO as GPIO | |
# /dev/spidev(bus).(dev) | |
SPI_BUS = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: nightlight | |
# Required-Start: $remote_fs | |
# Required-Stop: $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: A comforting light to keep you out of the dark | |
# Description: Toggle GPIO LED from MCP3304 ADC to OPT101 photodiode | |
### END INIT INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# SPI_MCP3304.py: read 8-channel ADC, based on http://www.havnemark.dk/?p=54 | |
# mcp3008_lm35.py - read an LM35 on CH0 of an MCP3008 on a Raspberry Pi | |
# mostly nicked from | |
# http://jeremyblythe.blogspot.ca/2012/09/raspberry-pi-hardware- spi-analog-inp$ | |
# Changed to work w. MCP3308 by Kim H. Rasmussen, June 2013 | |
import spidev | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# open/close CD/DVD tray from Raspberry Pi GPIO via H-Bridge | |
import RPi.GPIO as GPIO | |
import time | |
import sys | |
import signal | |
GPIO.setmode(GPIO.BOARD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import sys | |
GPIO.setmode(GPIO.BOARD) | |
C = 38 # G20 | |
D = 40 # G21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import sys | |
GPIO.setmode(GPIO.BOARD) | |
K1 = 38 # G20 | |
K2 = 7 # G4 | |
K3 = 36 # G16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# eject CD/DVD tray using GPIO to turn on motor until switch closes | |
import RPi.GPIO as GPIO | |
import signal | |
import sys | |
import time | |
GPIO.setmode(GPIO.BOARD) |