Using the keyboard to control your project

Now that the keyboard is connected, let's figure out how to accept commands on Raspberry Pi. Now that you can enter commands wirelessly, the next step is to create a program that can take these commands and then have your project execute them. There are a couple of options here; you'll see examples of both. The first is to simply include the command interface in your program. Let's take an example of the program you wrote to move your wheeled robot, dcmotor.py. If you want, you can copy that program using cp dcmotor.py remote.py.

In order to add user control, you need two new programming constructs, the while loop and the if statement. Let's add them to the program and then we will learn what they do. ...

Get Raspberry Pi Robotic Projects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.