Skip to content

Instantly share code, notes, and snippets.

View PhirePhly's full-sized avatar

Kenneth Finnegan PhirePhly

View GitHub Profile
// 2010 Kenneth Finnegan
// kennethfinnegan.blogspot.com
//
// Drives cross walk sign in standard cycle
// Outputs buffered through 400V TRIACs
// Runs on standard ATTiny85 with internal oscillator
#include <inttypes.h>
#include <avr/io.h>
// 2010 Kenneth Finnegan
// kennethfinnegan.blogspot.com
//
// Serial monitor to print a TTL serial line
// to an HD44780 LCD screen
// Runs on any Arduino platform
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
@PhirePhly
PhirePhly / lcdlowpower.c
Created September 26, 2010 00:24
Driving a raw LCD from MSP430
// 2010 Kenneth Finnegan
// http://kennethfinnegan.blogspot.com/
// Ultra-low power LCD counter experiment
#include "msp430G2231.h"
// Which digit is being displayed
volatile unsigned char mode;
// refresh periods spent in current mode
volatile unsigned char modecnt;
@PhirePhly
PhirePhly / logrotate.sh
Created November 26, 2010 09:01
logrotate.sh
#!/bin/sh
#
# Kenneth Finnegan, 2010
# kennethfinnegan.blogspot.com
#
# Counts service requests for the day and adds count to smaller log file
#
# To have run by cron at 23:59 daily, add the following to your crontab
# 59 23 * * * /mnt/storage/lighty/logrotate.sh
#!/bin/sh
# Kenneth Finnegan, 2010
# kennethfinnegan.blogspot.com
#
# status.sh - CGI script to print current Chumby health and statistics
#
# Install in web server cgi-bin/ folder
# Schedule with cron to prevent stale cache:
# 0 * * * * /.../cgi-bin/status.sh > /dev/null
#
// I2C library using USI hardware support
// Kenneth Finnegan, 2010
// kennethfinnegan.blogspot.com
// Heavily based on Atmel application note AVR310
#include <util/delay.h>
#include <avr/io.h>
#include <inttypes.h>
//#define PARAM_VERIFY
@PhirePhly
PhirePhly / ipaddrformat.awk
Created December 22, 2010 02:42
Set of scripts to log the Chumby's public IP address, then display it on a web page
# Kenneth Finnegan, 2010
# kennethfinnegan.blogspot.com
#
# AWK patterns to format alternating lines of date and geoip tags into
# single lines of date % ipaddr.
#
# 2010 12 15: Initial revision
/^[MTWSF]/ {printf ( "\n%s %% " ,$0)}
/.*"US".*"[0-9.]*"/{printf ("%s",$4)}
@PhirePhly
PhirePhly / XmasLights.c
Created December 25, 2010 06:48
Little pattern generator for Arduino-controlled Christmas lights
// Christmas light controller
// Drives three TRIAC channels for lights hung on outside of house
// Kenneth Finnegan, 2010
// kennethfinnegan.blogspot.com
#define ROOFL 12
#define ROOFR 11
#define WINDOW 13
@PhirePhly
PhirePhly / libEEPROM.c
Created January 16, 2011 00:18
AVR EEPROM Library
// Kenneth Finnegan, 2011 - GPLv2
// kennethfinnegan.blogspot.com
// Read a single byte from the given address
unsigned char EEPROM_read( unsigned int eeprom_addr ) {
// Spin-lock until EEPROM finishes prev write
while (EECR & (1<<EEPE)) ;
// Setup address register
EEAR = eeprom_addr;
// Start read
@PhirePhly
PhirePhly / lamp.c
Created January 30, 2011 21:08
Lamp Controller based on ATMega328
// 2010 Kenneth Finnegan
// kennethfinnegan.blogspot.com
//
// Control System for 4 channel lamp system
//
// Digital outputs are fed into TRIACs to control 120VAC
//
// Digital inputs come from push buttons and 120VAC light switch
// PC[0..3] - Push buttons