Page 247 - Hacking Roomba
P. 247
228 Part III — More Complex Interfacing
Listing 11-2 Continued
System.out.println(“Checking for Roomba... “);
if( roombacomm.updateSensors() )
System.out.println(“Roomba found!”);
else
System.out.println(“No Roomba. :( Is it turned
on?”);
System.out.println(“Playing some notes”);
roombacomm.playNote(72,10); // C
roombacomm.pause(200);
roombacomm.playNote(79,10); // G
roombacomm.pause(200);
roombacomm.playNote(76,10); // E
roombacomm.pause(200);
System.out.println(“Spinning left, then right”);
roombacomm.spinLeft();
roombacomm.pause(1000);
roombacomm.spinRight();
roombacomm.pause(1000);
roombacomm.stop();
// ...and so on...
System.out.println(“Disconnecting”);
roombacomm.disconnect();
}
}
Summary
Getting a Roomba on your LAN is pretty easy with the right tools. Now anyone on your net-
work can access Roomba and run the programs you write for it. No special serial port drivers
are needed, just an Internet connection. The Ethernet tether turns out to be a pretty good
replacement for the serial tether because dealing with Ethernet, as a user, is just simpler. The
Ethernet module and your computer do all the hard work. Ethernet has the added benefit of
giving you much longer cable lengths, up to 100 meters (325 feet). For the next chapter, the
Ethernet tether can function in a similar support role for the Wi-Fi adapter as the serial tether
did for the Bluetooth adapter: providing a known-good interface that is the same in all ways
except one is wired and the other wireless.