garethtdavies
3/14/2014 - 5:27 PM

Turning an alarm off with a Spark Core

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";
}