Skip to content

Instantly share code, notes, and snippets.

@garethtdavies
Created March 14, 2014 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethtdavies/9552598 to your computer and use it in GitHub Desktop.
Save garethtdavies/9552598 to your computer and use it in GitHub Desktop.
Turning an alarm off with a Spark Core
<?php
use Wensleydale\SparkCore;
use Wensleydale\SparkException;
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
//Get your access token from either the Spark Build site or make a token request
$accessToken = 'access_token';
//Create a new Spark instance
$core = SparkCore::make($accessToken);
//Set the device that you wish to interact with
$core->setDeviceId('device_id');
$core->setPin('D0');
$core->setValue('LOW');
try {
$result = $core->digitalWrite();
echo "The alarm is now off";
} catch (SparkException $e) {
echo "There was an issue with the digital write method";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment