Skip to content

Instantly share code, notes, and snippets.

View StuffAndyMakes's full-sized avatar

StuffAndyMakes StuffAndyMakes

View GitHub Profile
@StuffAndyMakes
StuffAndyMakes / Charlieplex12LEDs.cc
Last active April 30, 2024 13:10
Arduino sketch code for Charlieplexing 12 LEDs - accompanies project "Charlieplexing LEDs with an AVR ATmega328 (or Arduino)"
#define A 12
#define B 11
#define C 10
#define D 9
#define PIN_CONFIG 0
#define PIN_STATE 1
#define LED_COUNT 12
@StuffAndyMakes
StuffAndyMakes / CharlieplexingFaster.cc
Last active October 7, 2021 19:17
Optimized Arduino/AVR Charlieplexing Example
#define A 12
#define B 11
#define C 10
#define D 9
#define LED_COUNT 12
#define DDR_BYTE 0
#define PORT_BYTE 1
byte matrix[LED_COUNT][2] = {
@StuffAndyMakes
StuffAndyMakes / ipotti-2.device.nut
Created October 28, 2013 01:09
iPotti #2 Electric Imp Device Squirrel Code
// iPotti Number 2 - read value on ADC (ambient light sensor) to see if potti is in use
const SLEEP_DURATION = 5;
// nextReport counts up to FORCE_REPORT_COUNT and reports to server regardless of sensor reading
// to le the server know the device is still alive, then counter resets and starts again
const FORCE_REPORT_COUNT = 13; // about every two minutes
const LIGHT_CHANGE_THRESHOLD = 2000;
function readLighting() {
local adcValue = hardware.pin9.read();
@StuffAndyMakes
StuffAndyMakes / ipotti-2.agent.nut
Last active December 26, 2015 17:49
Agent code for iPotti #2 bathroom availability monitoring system
device.on( "lightChanged", function( json ) {
// Set URL to your web service
local url = "http://somedomain.com/api/for/ipotti";
// Set Content-Type header to json
local headers = { "Content-Type": "application/json" };
// encode data and log
local body = http.jsonencode( json );
@StuffAndyMakes
StuffAndyMakes / FitBitCheat_O_Matic.ino
Last active December 27, 2015 22:59
Arduino code for FitBit Cheat-O-Matic
#include <Servo.h>
#define SERVO_PIN 9
#define SPEED_POT 14
Servo fitBitShaker;
void setup() {
fitBitShaker.attach( SERVO_PIN );
pinMode( SPEED_POT, INPUT );
@StuffAndyMakes
StuffAndyMakes / iBeaconSample.m
Last active December 31, 2015 13:29
iOS 7 iBeacon partial example (implementation)
#import "iBeaconSample.h"
@implementation iBeaconSample
// your other code goes here, maybe...
- (void)initRegion {
// Set a proximityUUID
// On a Mac in the Terminal, you can use the uuidgen command to get a UUID
@StuffAndyMakes
StuffAndyMakes / iBeaconSample.h
Created December 16, 2013 20:20
iOS 7 iBeacon partial example (header)
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface iBeaconSample : NSObject <CLLocationManagerDelegate>
@property (strong, nonatomic) CLBeaconRegion *beaconRegion;
@property (strong, nonatomic) CLLocationManager *locationManager;
- (void)initRegion;
@StuffAndyMakes
StuffAndyMakes / Chase16LEDs.ino
Created September 14, 2014 22:08
Arduino Charlieplexing Demo Project
/*
* Chase16LEDs.ino
* Description: Quick, down-n-dirty demo of Charlieplexing LEDs on an Arduino
* http://StuffAndyMakes.com
*/
#define A 12
#define B 11
#define C 10
#define D 9
@StuffAndyMakes
StuffAndyMakes / printBigBinary.cpp
Created November 16, 2014 00:30
Quick Easy Binary Value Print Function
String printBigBinary( uint32_t n, int spacing ) {
int bitPosition = sizeof(n) * 8 - 1;
String bits = "";
while (bitPosition >= 0) {
bits += (n & (1UL<<bitPosition)) == (1UL<<bitPosition) ? "1" : "0";
if (bitPosition % spacing == 0) {
bits += " ";
}
bitPosition--;
}
@StuffAndyMakes
StuffAndyMakes / Charlieplex20LEDs.cpp
Last active November 6, 2024 19:10
Charlieplexing 20 LEDs
// pin defines
#define A 12
#define B 11
#define C 10
#define D 9
#define E 8
#define PIN_COUNT 5
#define PIN_CONFIG 0