Last active
December 25, 2015 13:19
-
-
Save davidkryzaniak/6983007 to your computer and use it in GitHub Desktop.
FargoPHP getting started
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 | |
//shutoff all relays | |
$myFargo->setAllTo(FALSE); | |
//change the state of relay #1 | |
$myFargo->relayFlipState(1); //#1 is now ON | |
//change the state of relay #0 (Labeled "Relay1" on the board) | |
echo "Relay #0 is currently: ".($myFargo->relayFlipState(0) ? 'On' : 'Off'); //#0 is now ON | |
echo "\n\r";//line break | |
//(Labeled "Relay2" on the board) | |
echo "Relay #1 is currently: ".($myFargo->relayFlipState(1) ? 'On' : 'Off'); //#1 is now OFF | |
echo "\n\r";//line break | |
echo "Relay #0 is currently: ".($myFargo->relayFlipState(0) ? 'On' : 'Off'); //#0 is now OFF | |
echo "\n\r";//line break | |
//turn on the odd numbered relays | |
$myFargo->setRelayState(1,TRUE); | |
$myFargo->setRelayState(3,TRUE); | |
$myFargo->setRelayState(5,TRUE); | |
$myFargo->setRelayState(7,TRUE); | |
//make sure #7 is really on | |
$myFargo->setRelayState(7,TRUE); | |
//get an array of the relays and their states | |
print_r($myFargo->getAllRelayStates()); | |
echo "\n\r";//line break | |
//try to turn ON #8 (which doesn't exist on an R8) | |
echo "Relay #8 is currently: ".$myFargo->relayFlipState(8); | |
echo "\n\r";//line break | |
//That's all for this example! Turn off all the relays | |
$myFargo->setAllTo(FALSE); | |
echo "Current Temperature: ".$myFargo->getTemp(); | |
//close the connection to the Fargo | |
$myFargo = NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment