Skip to content

Instantly share code, notes, and snippets.

View brian-lc's full-sized avatar

Brian Chamberlain brian-lc

View GitHub Profile
@brian-lc
brian-lc / converter.py
Last active December 31, 2017 13:24
Python file to convert a WAV file to raw bytes in a dot H file for the DAC on the Particle Photon
# -*- coding: utf-8 -*-
# NOTE: The WAV file must be 16bit-PCM format.
# It must be encoded at 22050Hz.
# Only mono audio files supported at this time.
# Steps to create the file in Audacity:
# 1) Open the WAV file in Audacity.
# 2) If it is stereo, split the Stereo track to mono
# 3) Delete one of the channels
# 4) Set the Project Rate to 22050Hz
# 5) Set the Sample Format to 16-bit PCM
@brian-lc
brian-lc / SFE_TSL2561.h
Created November 15, 2015 19:52
SFE_TSL2561.h
/*
SFE_TSL2561 illumination sensor library for Arduino
Mike Grusin, SparkFun Electronics
This library provides functions to access the TAOS TSL2561
Illumination Sensor.
Our example code uses the "beerware" license. You can do anything
you like with this code. No really, anything. If you find it useful,
buy me a beer someday.
@brian-lc
brian-lc / SFE_TSL2561.cpp
Created November 15, 2015 19:51
SFE_TSL2561.cpp
/*
SFE_TSL2561 illumination sensor library for Arduino
Mike Grusin, SparkFun Electronics
This library provides functions to access the TAOS TSL2561
Illumination Sensor.
Our example code uses the "beerware" license. You can do anything
you like with this code. No really, anything. If you find it useful,
buy me a beer someday.
@brian-lc
brian-lc / breville_tea_audio.ino
Last active October 1, 2015 15:07
Audio code for the adafruit wav shield
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"
SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the filesystem on the card
FatReader f; // This holds the information for the file we're play
@brian-lc
brian-lc / breville_tea_bot.ino
Last active October 5, 2015 00:00
Power monitoring and state inspection of Breville tea maker
#include "EmonLib.h" // Include Emon Library
EnergyMonitor Emon1; // Create an instance
int LedPin = 5;
int BasketDownPin = 2; // Will pulse this pin 10ms when the basket drops
int BasketUpPin = 3; // Will pulse this pin 10ms when the basket raises
double IrmsBase = 0.0; // Baseline current sampled at startup
int BaseLen = 5;
double Baseline[5]; // History for baseline so we update baseline overtime
String States[3] = {"Waiting", "Heating", "Basket"};
@brian-lc
brian-lc / pg_scraper.coffee
Last active August 29, 2015 14:23
Scrapes the PG&E website for energy and billing data using your login/password
# Call this from casperjs cli like this
# casperjs pge_scrape.coffee --user=<your_username> --password=<your_password>
# Works on Phantom 1.98 and Casper 1.1 beta
casper = require('casper').create
viewportSize: {width: 800, height: 600},
pageSettings: {webSecurityEnabled: false}
user = casper.cli.get('user')
password = casper.cli.get('pass')
@brian-lc
brian-lc / CO2BarGraph.ino
Last active February 9, 2021 13:39
CO2 Sensor Code
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include <SPI.h>
#include <Adafruit_BLE_UART.h>
#include "DHT.h"
#define ADAFRUITBLE_REQ 10
#define ADAFRUITBLE_RDY 3
#define ADAFRUITBLE_RST 9
@brian-lc
brian-lc / SenseAirCO2K30_Breadboard.svg
Last active August 29, 2015 14:18
SVG content for SenseAir CO2 Fritzing part
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brian-lc
brian-lc / packet.h
Created March 15, 2015 09:01
Sample Arduino for Bartendro dispenser - Packet.h
#ifndef __PACKET_H__
#define __PACKET_H__
#include <stdint.h>
/* IMPORTANT!!
This file defines the constants and packet structure for the communication
between the router and the dispensers. These values are duplicated in
the python code in ui/bartendro/router/driver.py. This should be improved
at some point.
@brian-lc
brian-lc / bartendro.c
Last active March 8, 2024 01:50
Sample Arduino code for a Bartendro dispenser
#include "packet.h"
#include <stdint.h>
#define SYNC_PIN 4
#define BUTTON_PIN 3
void setup()
{
Serial.begin(9600);
delay(100);