Skip to content

Instantly share code, notes, and snippets.

@harrisonhjones
harrisonhjones / gist:403398d12fe8f018bbad
Last active August 29, 2015 14:07
Halloween Prop Sparkcore Code
int RELAY1 = D0;
int RELAY2 = D1;
int RELAY3 = D2;
int MOTION1 = D3;
unsigned long lastMotionTime = 0;
int propDelay = 10000; // In milliseconds(10 seconds)
int propOnTime = 20000; // In milliseconds(20 seconds)
int state = 0; // Normal operation = 0, Waiting to actuate prop in 10 seconds = 1, Actuaing props for 20 seconds = 2
@harrisonhjones
harrisonhjones / SparkCoreEventRecorder.js
Last active April 28, 2016 11:59
NodeJS SparkCore Event Recorder
// Includes
var EventSource = require('eventsource');
var mysql = require('mysql');
// Variables
var deviceID = "***FILL THIS IN***";
var accessToken = "***FILL THIS IN***";
// Mysql Connection
var connection = mysql.createConnection({
vid = videoinput('winvideo', 1, 'RGB24_320x240'); %select input device
hvpc = vision.VideoPlayer; %create video player object
src = getselectedsource(vid);
vid.FramesPerTrigger =1;
vid.TriggerRepeat = Inf;
vid.ReturnedColorspace = 'rgb';
src.FrameRate = '30';
start(vid)
// This #include statement was automatically added by the Spark IDE.
#include "OneWire/OneWire.h"
// This #include statement was automatically added by the Spark IDE.
#include "spark-dallas-temperature/spark-dallas-temperature.h"
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS D3
#define TEMPERATURE_PRECISION 9
#pragma SPARK_NO_PREPROCESSOR
// DS18B20 Thermometer Stuff
#include "DallasTemperature.h"
#include "OneWire/OneWire.h"
#define ONE_WIRE_BUS D1
#define TEMPERATURE_PRECISION 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress inWaterThermometer = { 0x28, 0x2E, 0x54, 0x0A, 0x06, 0x0, 0x0, 0xFB };
package simplejavaserver;
import java.net.*;
import java.io.*;
public class SimpleJavaServer extends Thread
{
private ServerSocket serverSocket;
public SimpleJavaServer(int port) throws IOException
@harrisonhjones
harrisonhjones / gist:d315732f278cd523b1bf
Last active August 29, 2015 14:14
RGBEffect Demo 1
#include "RGBEffect.h"
RGBEffect led;
// Define a color sequence of 6 colors
unsigned int colorSeq[6] = {1,2,3,4,5,6}; // Red, White, Blue, Green
void setup() {
Spark.function("blinkon", blink);
Spark.function("blinkoff", blinkoff);
// Define a few colors
@harrisonhjones
harrisonhjones / application.cpp
Created January 29, 2015 20:35
Spark Tinker
/**
******************************************************************************
* @file application.cpp
* @authors Satish Nair, Zachary Crockett and Mohit Bhoite
* @version V1.0.0
* @date 05-November-2013
* @brief Tinker application
******************************************************************************
Copyright (c) 2013 Spark Labs, Inc. All rights reserved.
@harrisonhjones
harrisonhjones / application.cpp
Last active October 9, 2015 07:22
Spark Community - kokoro - Web Browser Issue
// Original Spark Community Thread: http://community.spark.io/t/how-to-access-the-core-via-we-browser/9711
// Code adapted from: http://arduino.cc/en/Tutorial/WebServer
/* Includes ------------------------------------------------------------------*/
#include "application.h"
SYSTEM_MODE(AUTOMATIC);
TCPServer server = TCPServer(80);
@harrisonhjones
harrisonhjones / application.cpp
Created February 5, 2015 06:16
Spark SubPub Issue
#include "application.h"
char lastTimeRec1[40];
char lastTimeRec2[40];
unsigned long lastTime = 0UL;
char publishString[40];
bool whichOne = false;
void handleTest1( const char * event, const char * data );