Page 271 - Hacking Roomba
P. 271
252 Part III — More Complex Interfacing
Listing 12-2 Continued
}
else if( $cmd == ‘spinright’ ) {
roomba_spin_right( $vel );
}
else if( $cmd == ‘sensors’ ) {
$sensors = roomba_read_sensors();
$c = count($sensors);
for( $i=1; $i<=$c; $i++ ) {
printf(“sensors[$i]: %x\n”, $sensors[$i]);
}
}
else if( $cmd == “drive” ) {
$vel = $_GET[‘velocity’];
$rad = $_GET[‘radius’];
roomba_drive( $vel, $rad );
}
?>
</pre>
</body>
</html>
Figure 12-12 shows what the script looks like in the browser when run.
FIGURE 12-12: Using the PHP Roomba program roombacmd.php