Skip to content

Instantly share code, notes, and snippets.

@cmsunu28
cmsunu28 / blink.js
Created September 30, 2014 23:45
Blink an LED with Javascript!
@cmsunu28
cmsunu28 / weatherlight.js
Last active August 29, 2015 14:07
An LED that turns on when it's going to rain
/*jslint node: true */
"use strict";
var request = require("request");
var spark = require("spark");
//change this URL to reflect your own city.
var url = 'http://api.openweathermap.org/data/2.5/forecast/daily?q=San%20Francisco,CA&cnt=1&mode=json';
// This #include statement was automatically added by the Spark IDE.
#include "SparkButton/SparkButton.h"
#include "math.h"
SparkButton b = SparkButton();
int state=0; // sets state of the reactor
// 0: breathing quietly
// 1: received notice of repulsor firing
@cmsunu28
cmsunu28 / repulsor.ino
Last active August 29, 2015 14:20
Repulsor
// This #include statement was automatically added by the Spark IDE.
#include "SparkButton/SparkButton.h"
SparkButton b = SparkButton();
// set a bunch of default values for variables we will use later
int lastY=31;
int lastlit=1;
int xValue;
int yValue;
Servo myservo;
int pos = 0;
int holdpos = 90;
int recoilpos = 90;
int hitpos = 180;
int servodelay = 200;
void go(const char *event, const char *data) {
@cmsunu28
cmsunu28 / Photoresistor-Variable.ino
Created May 7, 2015 16:14
Photoresistors Part One: Spark Variable and Spark Function
/*---OH HI THERE, WELCOME TO THE PHOTORESISTOR PROGRAM---
Part One: Spark Variable and Spark Function
We've heavily commented this code for you. If you're a pro, feel free to ignore it.
Comments start with two slashes or are blocked off by a slash and a star.
You can read them, but your device can't.
It's like a secret message just for you.
@cmsunu28
cmsunu28 / photoresistor-variable.html
Created May 7, 2015 16:48
Photoresistors Part One: Turning on and off from the internet
<!-- Replace your-device-ID-goes-here with your actual device ID
and replace your-access-token-goes-here with your actual access token-->
<center>
<br>
<br>
<br>
<form action="https://api.spark.io/v1/devices/your-device-ID-goes-here/led?access_token=your-access-token-goes-here" method="POST">
Tell your device what to do!<br>
<br>
@cmsunu28
cmsunu28 / photoresistor-breakbeam.ino
Created May 7, 2015 22:47
Photoresistors Part Two: Sensing Motion
/*---OH HI THERE, WELCOME TO THE PHOTORESISTOR PROGRAM---
Part Two: Sensing motion with your photoresistor
We're going to assume that you've already checked out Part One!
This app will make it so that you know when the beam of light
between the LED and the photoresistor is broken.
It essentially makes a little tripwire sensor out of your LED and photoresistor.
@cmsunu28
cmsunu28 / photoresistor-subscribe-publish.ino
Created May 7, 2015 23:14
Photoresistors Part Three: Subscribe and Publish
/*---OH HI THERE, WELCOME TO THE PHOTORESISTOR PROGRAM---
Part Three-- Publish and Subscribe with your Photoresistor and a Buddy
We will assume here that you've already done part one.
Now for Part Two-- the part where you get a buddy.
Go find a buddy who also has a Spark device.
Each of you will pick a unique event name
(make it weird so that no one else will have it)
@cmsunu28
cmsunu28 / arc-reactor.ino
Created October 2, 2015 19:57
arc reactor
// This #include statement was automatically added by the Particle IDE.
#include "InternetButton/InternetButton.h"
#include "math.h"
// SYSTEM_MODE(SEMI_AUTOMATIC);
long startTime2 = 0;
int alreadyDown2 = 0;