Skip to content

Instantly share code, notes, and snippets.

View jscrane's full-sized avatar

Stephen Crane jscrane

View GitHub Profile
@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 / xbee.c
Created February 17, 2012 12:19
XBee packet I/O (linux)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
@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)
{
@jscrane
jscrane / xbee.h
Created February 17, 2012 12:46
XBee packet I/O (linux) header
int open_device(char *device, int speed);
#define AT_REQUEST 0x08
#define REMOTE_AT_REQUEST 0x17
#define AT_RESPONSE 0x88
#define REMOTE_AT_RESPONSE 0x97
struct at_response {
uint8_t api_id, frame_id;
uint8_t cmd[2];
@jscrane
jscrane / pertelian.ino
Created April 13, 2012 15:09
sketch for wireless serial lcd display
#define __STDC_LIMIT_MACROS 1
#include <stdint.h>
#define BOFF 2
#define BON 3
#define RS 3
#define EN 4
int bitmap[] = {6, 7, 8, 13, 12, 11, 10, 9 };
@jscrane
jscrane / breathe.ino
Created June 17, 2012 14:49
Sketch demonstrating software PWM and putting ATtiny85 into deep sleep
#define __STDC_LIMIT_MACROS 1
#include <stdint.h>
#include <avr/sleep.h>
#include <avr/interrupt.h>
void setup() {
pinMode(0, OUTPUT);
pinMode(2, INPUT);