Skip to content

Instantly share code, notes, and snippets.

View dmiddlecamp's full-sized avatar

David Middlecamp dmiddlecamp

View GitHub Profile
void setup() {
initWifi();
}
void loop() {
}
void initWifi() {
@dmiddlecamp
dmiddlecamp / battery_counter.ino
Created July 11, 2014 15:45
turn a spark core cc3000 on/off every 45 seconds, give or take
#include "application.h"
#include "spark_disable_wlan.h"
#include "spark_disable_cloud.h"
int state = 0;
int awake = 0;
unsigned int lastWakeup = 0;
//wakeup once a minute
unsigned int wakeupDelay = 60 * 1000;
@dmiddlecamp
dmiddlecamp / packetClient.js
Last active August 29, 2015 14:04
CC3000 failing reads at 256 byte boundaries
/**
* Created by middleca on 7/17/14.
*/
var when = require('when');
var settings = {
ip: "192.168.1.49",
port: 80,
start_size: 0,
end_size: 1024
/*
* Bitcoin Price Index JSON Parsing TCP Client Example
* BDub @ Technobly.com 6/27/2014
* LICENSE: MIT (C) 2014 BDub
*
*/
#pragma SPARK_NO_PREPROCESSOR
#include "application.h"
//
// To start out we're going to define some things to allow for cleaner code below; let's start with our twitter auth info:
//
#define TWITTER_OAUTH "ENTER YOUR ACCESS TOKEN HERE"
#define LIB_DOMAIN "arduino-tweet.appspot.com"
//
// lets be good Twitter citizens and limit the number of times our pumpkins tweets when it's calm. Below you can see it's set to
// send a calm tweet every 45 minutes at the absolute most. It will send an "alarm" tweet only every minute
//
@dmiddlecamp
dmiddlecamp / firewalker_spark.ino
Created October 30, 2014 01:58
untested quick port of firewalker code!
// This #include statement was automatically added by the Spark IDE.
#include "neopixel/neopixel.h"
// 'Firewalker' LED sneakers sketch for Adafruit NeoPixels by Phillip Burgess
const uint8_t gamma[] = { // Gamma correction table for LED brightness
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
@dmiddlecamp
dmiddlecamp / mousetrap
Created November 6, 2014 23:23
Latest Mousetrap Code
#define TWITTER_OAUTH "___insert_your_oauth_string_here___"
#define LIB_DOMAIN "arduino-tweet.appspot.com"
#pragma SPARK_NO_PREPROCESSOR
// In case we're compiling locally:
#include "application.h"
void next_alarm_tweet();
void next_calm_tweet() ;
@dmiddlecamp
dmiddlecamp / holiday_strip.ino
Last active August 29, 2015 14:11
Holiday Strip code
// This #include statement was automatically added by the Spark IDE.
#include "neopixel/neopixel.h"
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 300
#define PIXEL_TYPE WS2812B
int reds[PIXEL_COUNT];
int greens[PIXEL_COUNT];
@dmiddlecamp
dmiddlecamp / TempSensor.h
Last active August 29, 2015 14:12
latest temp sensor package
#include "application.h"
class TempSensor {
public:
char *id ;
uint8_t rom[8];
float value ;
int updated = 0;
};
@dmiddlecamp
dmiddlecamp / main.ino
Created January 8, 2015 16:29
a workaround to detect and recover when event subscriptions are lost
unsigned int last_heartbeat = 0;
#define HEARTBEAT_PERIOD_SECONDS 60
#define MAX_MISSED_HEARTBEATS 3
void setup() {
Serial.begin(115200);
Spark.subscribe("heartbeat", heartbeat_handler);
//Spark.subscribe("heartbeat", heartbeat_handler, MY_DEVICES);
last_heartbeat = millis();
}