Skip to content

Instantly share code, notes, and snippets.

View jscrane's full-sized avatar

Stephen Crane jscrane

View GitHub Profile
@jscrane
jscrane / tinyrelay.ino
Created February 20, 2014 13:41
TinyRelay sketch
#include <SoftwareSerial.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <EEPROM.h>
RF24 radio(2, 3);
RF24Network network(radio);
const int rx = 1, tx = 0;
@jscrane
jscrane / prob6041x
Created April 16, 2014 09:57
Probability Cheat Sheet
Counting
------------
**Permutations**
$n! = n(n-1)(n-2) ... 1$
**k-Permutations**
$\frac{n!}{(n-k)!}$
**Combinations**
@jscrane
jscrane / gist:94d2dd9e465b121ab937
Created February 18, 2015 19:05
Basic Page Rank algorithm with scipy.sparse
import sys
import scipy.sparse as sps
import numpy as np
nodes = 1000000
beta = 0.8
eps = 1e-6
V = set()
degs = {}
@jscrane
jscrane / tinytest.ino
Last active August 29, 2015 14:20
Interrupted example for ATtiny85
#include <Interrupted.h>
#define LED 0
#define TIMER 1
#define BUTTON 2
Watchdog timer(TIMER, 1);
External button(BUTTON, LOW);
PinChangeGroup portb;
PinChange led(LED, portb);
@jscrane
jscrane / frankenmeter.pde
Created May 5, 2011 14:10
Arduino sketch for Frankenstein's Thermometer
#include <math.h>
#define THERMISTOR 7
#define SWITCH 1
#define A_PIN 4
const double beta = 3977.0;
const double zeroC = 273.15;
const double tzero = 25 + zeroC;
@jscrane
jscrane / Arduino.mk
Created July 13, 2011 10:34
Arduino Makefile
########################################################################
#
# Arduino command line tools Makefile
# System part (i.e. project independent)
#
# Copyright (C) 2010 Martin Oldfield <m@mjo.tc>, based on work that is
# Copyright Nicholas Zambetti, David A. Mellis & Hernando Barragan
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
@jscrane
jscrane / twilight.pde
Created July 21, 2011 13:42
Arduino sketch for Twilight gadget
#define LIGHT 5
#define MOTION 0
#define SWITCH 1
#define LEDS 2
#define DUSK 4
#define HZ 4
#define SAMPLES (15*HZ)
#define ON_DELAY (30*60*HZ)
#define OFF_DELAY (15*HZ)
@jscrane
jscrane / foo.pl
Created November 11, 2011 17:33
Skeleton Perl script to program sensor attached to XBee
#!/usr/bin/perl
use warnings;
use Xbee::API;
use Data::Dumper;
my $port = "/dev/ttyUSB0";
my $end_device = "0013a20040769646";
my $remaddr = pack( "H*", $end_device );
my $devaddr = pack( "H4", "fffe" );
@jscrane
jscrane / twilight2.ino
Created January 30, 2012 14:10
Arduino sketch for Twilight gadget, version 2
#include <EEPROM.h>
#define MOTION 1
#define SWITCH 0
#define LIGHT 2
#define LDR 3
#define HZ 4
#define SAMPLES (15*HZ)
#define ON_DELAY (15*60*HZ)
@jscrane
jscrane / lcd.c
Created February 17, 2012 12:22
HD44780 LCD + XBee
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include "xbee.h"
#include "lcd.h"
static int send_sync(int fd, uint8_t *remote, char *cmd, uint8_t *data, uint16_t n)
{