Skip to content

Instantly share code, notes, and snippets.

@harrisonhjones
harrisonhjones / application.cpp
Created June 12, 2015 16:41
Particle - Example Blinky
// This program will blink an led on and off every second.
// It blinks the D7 LED on your Particle device. If you have an LED wired to D0, it will blink that LED as well.
// First, define the pins we are going to use.
int led = D0; // You'll need to wire an LED to this one to see it blink.
int led2 = D7; // This one is the little blue LED on your board. On the Photon it is next to D7, and on the Core it is next to the USB jack.
// This routine runs only once when the device boots up or is reset
void setup() {
// We are going to tell our device that D0 and D7 (which we named led and led2 respectively) are going to be output
#define APP_VERSION 1.1
double distance = 0;
double echo = 0;
int ultraSoundSignal = D0; // Ultrasound signal pin
// Elapsed Millis Stuff
unsigned int publishInterval = 2000; // Every 2000 ms (2 seconds)
elapsedMillis timeElapsed; //declare global if you don't want it reset every time loop runs
SYSTEM_MODE(MANUAL);
void setup()
{
Serial.begin(9600);
WiFi.on();
WiFi.connect();
}
void loop()
@harrisonhjones
harrisonhjones / gist:1bfc327f90e18ea17e62
Created April 30, 2015 05:14
QueuedPublishEventsSpark
char eventMessages[10][65]; // 10 messages of a max 65 char length
char eventMessage[65]; // A buffer for outgoing publish events
int queueIndex = -1; // -1 = nothing to send, 0+ = a message is queued
// In your main loop();
@harrisonhjones
harrisonhjones / gist:e1dc35ebfe130b731fcf
Created April 23, 2015 19:46
Spark - DHT22 Logger to Webhook
/* Includes ------------------------------------------------------------------*/
//#include "application.h"
#include "PietteTech_DHT.h" // From: https://github.com/piettetech/PietteTech_DHT
/* Function prototypes -------------------------------------------------------*/
void dht_wrapper(); // must be declared before the lib initialization
// Explicit Declaration of System Mode
SYSTEM_MODE(AUTOMATIC);
@harrisonhjones
harrisonhjones / application.cpp
Last active August 29, 2015 14:19
Spark Download File by Chunk
/* Includes ------------------------------------------------------------------*/
#include "application.h"
#include "flashHelper.h"
#include "Adafruit_mfGFX.h"
#include "Adafruit_SharpMem.h"
extern char* itoa(int a, char* buffer, unsigned char radix);
// Debug
// Turn ON DEBUG statements
@harrisonhjones
harrisonhjones / sparkFunction.php
Last active August 29, 2015 14:16
Spark PHP Examples
<?php
echo "Program Start<br/>";
/* Desired Curl Command
curl https://api.spark.io/v1/devices/0123456789abcdef/brew \
-d access_token=123412341234 \
-d "args=coffee"
*/
@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 );
@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 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.