Skip to content

Instantly share code, notes, and snippets.

View dmiddlecamp's full-sized avatar

David Middlecamp dmiddlecamp

View GitHub Profile
@dmiddlecamp
dmiddlecamp / nyan.ino
Created January 20, 2015 20:34
Slightly more fancy version with auto-off
#define AUTO_OFF 1 /* minutes */
unsigned int lastOn = 0;
void setup() {
Spark.function("shoutRainbows", nyanHandler);
}
void loop() {
//nothing to see here!
if (lastOn > 0) {
@dmiddlecamp
dmiddlecamp / laser.ino
Created January 22, 2015 01:49
keen laser code
int laser = 0;
unsigned int lastPublish = 0;
bool lastState = false;
void setup() {
pinMode(A0, INPUT_PULLDOWN);
pinMode(D7, OUTPUT);
}
void loop() {
@dmiddlecamp
dmiddlecamp / serial_bridge
Last active August 29, 2015 14:14
pipe serial1 -> serial and vice versa
SYSTEM_MODE(MANUAL);
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
pinMode(D7, OUTPUT);
}
void loop() {
if (Serial1.available()) {
@dmiddlecamp
dmiddlecamp / publish_demo.ino
Created February 12, 2015 15:38
a working demo of public/private publish / subscribe for multiple cores
#define publish_delay 10000
#define PUBLISH_TO "some_private_event_1"
#define PUBLIC_EVENT "some_public_event_1"
unsigned int lastPublish = 0;
void setup() {
Serial.begin(115200);
//the firmware uses the event name to figure out which handler it should toss things to, and doesn't select based on privacy, so we need to also make the event names differ in this example.
@dmiddlecamp
dmiddlecamp / neopixel.cpp
Created May 26, 2015 15:27
updated neopixel library for the photon
/*-------------------------------------------------------------------------
Spark Core library to control WS2811/WS2812 based RGB
LED devices such as Adafruit NeoPixel strips.
Currently handles 800 KHz and 400kHz bitstream on Spark Core,
WS2812, WS2812B and WS2811.
Also supports:
- Radio Shack Tri-Color Strip with TM1803 controller 400kHz bitstream.
- TM1829 pixels
@dmiddlecamp
dmiddlecamp / coco-button.ino
Created June 12, 2015 16:06
Available / Busy / Away button for Mikky
// This #include statement was automatically added by the Spark IDE.
#include "HttpClient/HttpClient.h"
// This #include statement was automatically added by the Spark IDE.
#include "SparkButton/SparkButton.h"
#define START_COLOR 25,25,25
#define BTN1_COLOR 200,0,0
#define BTN2_COLOR 0,200,0
#define BTN3_COLOR 75,50,200
#include "application.h"
#include "ctrl.h"
Ctrl::Ctrl()
{
init();
}
Ctrl::~Ctrl(){
}
//SYSTEM_MODE(MANUAL);
// This #include statement was automatically added by the Spark IDE.
#include "SparkButton/SparkButton.h"
#include "math.h"
#define BASE_NON_CHEER_INTENSITY 64
#define CHEER_DURATION 25.0
//bool state = false;
#define DEFAULT_BRIGHTNESS 1
#define NUM_PIXELS 8
float pixels[NUM_PIXELS];
#define KERNEL_SIZE 5
float kernel[KERNEL_SIZE] = { 1, 0.8, 0.4, 0.8, 1 };
int kernelPos = -1 * KERNEL_SIZE;
// This #include statement was automatically added by the Particle IDE.
#include "neopixel/neopixel.h"
#include "math.h"
SYSTEM_MODE(MANUAL);
#define RANDOM_SPIRITS true
#define RANDOM_SPIRIT_CHANCE 0.10