Code

file_7176.txtC/C++
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>

#include "version.h"

void setup() {
  Scout.setup(SKETCH_NAME, SKETCH_REVISION, SKETCH_BUILD);
  // Add custom setup code here
}

void loop() {
  Scout.loop();
  // Add custom loop code here
  if (digitalRead(2) == 0) {
    Led.green();
  } else {
    Led.red();
  }
}
file_7177.jsJavaScript
var pinocc = require("pinoccio");
var applescript = require("applescript");
var colors = require('colors');

var api = pinocc("{{api-key}}");

var application = "Spotify";

function control(app, command) {
	var com;
	switch(command){
		case "playpause":
			com = 'tell application "' + app + '" to playpause'
			break;
		case "next":
			com = 'tell application "' + app + '" to next track'
			break;
		case "previous":
			com = 'tell application "' + app + '" to previous track'
			break;
	}

	applescript.execString(com, function(err, rtn) {
  		if (err) {
    	// Something went wrong!
    	console.error("ERROR!!!");
  		}
	});
}
var s = api.sync();

s.on("data", function(data){
	data = data.data;
	if(data.type === "digital" && data.troop === '2' && data.scout === '3'){
		if (data.value.state[0] === 0) {
			application = "Spotify"
			console.log('Now Using: '+ 'Spotify'.green);
		} else if(data.value.state[0] === 1) {
			application = "iTunes"
			console.log('Now Using: '+ 'iTunes'.red);
		}
	} else if (data.type === "digital" && data.troop === '2' && data.scout === '4') {
		if (data.value.state[0] === 0) {
			control(application, "previous");
		} else if(data.value.state[1] === 0) {
			control(application, "playpause");
		} else if(data.value.state[2] === 0) {
			control(application, "next");
		}
	}
});

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

DHT22 Sensor and Pinoccio
  • 1,586
  • 5

Full instructions

Using DHT22 Temperature and Humidity sensor with Pinoccio

Mesh Your Brain
  • 3,344
  • 21

Full instructions

Build your own Internet of Brains with this wireless EEG hack!

Human Presence Detection & Visualization
  • 1,048
  • 8

Full instructions

Team Cogitate's social radar displays people nearby as a set of glowing orbs

Data Painting
  • 1,548
  • 11

Full instructions

Create ephemeral, data-rich light paintings in the air, using a motion sensor.

Data Painting

Jake Ingman

Hideous Arc Reactor Sweater (WIP)
  • 774
  • 6

Work in progress

Power through the holiday slump with this festive, EEG-reactive sweater!

Solar Powered Pinoccio Scout
  • 1,044
  • 9

Run your wireless mesh forever with Adafruit's solar LiPo charger

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback