Skip to content

Instantly share code, notes, and snippets.

@kentros
kentros / keypad.py
Created February 21, 2018 02:35
how-to-use-a-4x4-keypad-in-python
# stolen from https://raspberrypi.stackexchange.com/questions/53665/how-to-use-a-4x4-keypad-in-python
from pad4pi import rpi_gpio
# Setup Keypad
KEYPAD = [
["1","2","3","A"],
["4","5","6","B"],
["7","8","9","C"],
["*","0","#","D"]
]
@kentros
kentros / pir.py
Created February 17, 2018 04:44
Passive Infrared Sensor code for a Raspberry Pi
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BCM)
PIR_PIN = 25
GPIO.setup(PIR_PIN, GPIO.IN)
def MOTION(PIR_PIN):
print 'Motion Detected! ' + time.ctime()
@kentros
kentros / digitaltube.c
Created February 17, 2018 04:25
Slightly modified TM1637 C code
/*
* Adapted from http://learn.linksprite.com/raspberry-pi/how-to-use-4-digit-7-segment-module-on-raspberrypi/
* Removes unwanted leading 0 digit on the time, goes with 12-hour format, sets brightness down to typical.
*/
#include "TM1637.h"
#include <stdio.h>
#include <time.h>
#define clk 4//pins definitions for TM1637 and can be changed to other ports
#define dio 5
@kentros
kentros / trivia.clj
Created July 12, 2016 16:27
Simple clojure trivia plugin for lazybot
(ns lazybot.plugins.trivia
(:use (lazybot registry info))
(:require [clojure.string :as s]
[clojure.java.io :as io]))
(use '[incanter.stats :only (levenshtein-distance)])
(def answer (atom ""))
(def buzzer (atom 0))