Skip to content

Instantly share code, notes, and snippets.

@Immortal-
Created April 7, 2016 17:28
Show Gist options
  • Save Immortal-/bb8f76e0a694dade5ffcce6027e1876e to your computer and use it in GitHub Desktop.
Save Immortal-/bb8f76e0a694dade5ffcce6027e1876e to your computer and use it in GitHub Desktop.
Using Onion Omega's GPIO using php
<?php
//When I get bored again Ill turn this into a library.
function SetIO($pin, $value)
{
exec("fast-gpio set $pin $value 2>&1", $output);
return explode(': ',$output[0])[1];
}
function ReadIO($pin)
{
exec("fast-gpio read $pin 2>&1", $output);
return explode(': ',$output[0])[1];
}
function SetPWM($pin, $hZ, $dutyCyclePercent)
{
exec("fast-gpio pwm $pin $hZ $dutyCyclePercent 2>&1", $output);
return explode(': ',$output[0])[1];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment