Created
July 9, 2012 23:15
-
-
Save aaronpearce/3079700 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| /* | |
| Quick Script for testing bot | |
| GPIO Pin Layout | |
| 17 = Right Motor Forwards | |
| 18 = Right Motor Backwards | |
| 22 = Left Motor Forwards | |
| 23 = Left Motor Backwardsß | |
| */ | |
| array_shift($argv); | |
| if(count($argv) == 2) { | |
| $arg1 = $argv[0]; | |
| $arg2 = $argv[1]; | |
| // Prevent both going at once and burning it out | |
| if(!((($arg1 == 17) && ($arg2 == 18)) || (($arg1 == 22) && ($arg2 == 23)))) { | |
| if(file_get_contents("/sys/class/gpio/gpio".$arg1."/value") == 0) { | |
| shell_exec('echo "1" > /sys/class/gpio/gpio'.$arg1.'/value'); | |
| } else { | |
| shell_exec('echo "0" > /sys/class/gpio/gpio'.$arg1.'/value'); | |
| } | |
| if(file_get_contents("/sys/class/gpio/gpio".$arg2."/value") == 0) { | |
| shell_exec('echo "1" > /sys/class/gpio/gpio'.$arg2.'/value'); | |
| } else { | |
| shell_exec('echo "0" > /sys/class/gpio/gpio'.$arg2.'/value'); | |
| } | |
| } else { | |
| echo "Can't run those pins together!\n"; | |
| } | |
| } else if(count($argv) == 1) { | |
| $arg1 = $argv[0]; | |
| if(file_get_contents("/sys/class/gpio/gpio".$arg1."/value") == 0) { | |
| shell_exec('echo "1" > /sys/class/gpio/gpio'.$arg1.'/value'); | |
| } else { | |
| shell_exec('echo "0" > /sys/class/gpio/gpio'.$arg1.'/value'); | |
| } | |
| } else { | |
| echo "Too many args!\n"; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment