Created
March 14, 2014 17:27
-
-
Save garethtdavies/9552598 to your computer and use it in GitHub Desktop.
Turning an alarm off with a Spark Core
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
<?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