Initial commit
This commit is contained in:
		
							
								
								
									
										22
									
								
								examples/basic.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								examples/basic.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
require_once __DIR__."/../vendor/autoload.php";
 | 
			
		||||
 | 
			
		||||
use NoccyLabs\Linux\Gpio;
 | 
			
		||||
 | 
			
		||||
try {
 | 
			
		||||
    $gpio = new Gpio\Gpio();
 | 
			
		||||
} catch (Gpio\Exception $e) {
 | 
			
		||||
    error_log("Error: {$e}");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$pin = $gpio->export(0);
 | 
			
		||||
$pin->setInterrupt("rising", function() {
 | 
			
		||||
    echo "Interrupt on GPIO0\n";
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
while(true) {
 | 
			
		||||
    // We need to call this for our interrupt status to be polled
 | 
			
		||||
    $gpio->update();
 | 
			
		||||
    usleep(10000);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user