Skip to content

Instantly share code, notes, and snippets.

@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
package simplejavaserver;
import java.net.*;
import java.io.*;
public class SimpleJavaServer extends Thread
{
private ServerSocket serverSocket;
public SimpleJavaServer(int port) throws IOException
#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 };
// 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
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)
@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({
@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