This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint node: true */ | |
"use strict"; | |
var spark =require('spark'); | |
spark.on('login', function() { | |
// If login is successful we get and accessToken, | |
// we'll use that to call Spark API ListDevices | |
var devicesPr = spark.listDevices(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*---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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*---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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*---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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
OlderNewer