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
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
// 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
// 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
/*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
/*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(); |
NewerOlder