Using the keyboard to control your project
Now the keyboard is connected, let's figure out how to accept commands on the BeagleBone Black.
Prepare for lift off
You can now 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 choices here and I'll give you examples of both. The first is simply to include the command interface in your program. Let's take the example of the program you wrote to move your wheeled robot, robot.py
. If you like you can copy that program using cp robot.py remote.py
. The following screenshot shows a listing of the current program in the area you want to change:
Engage thrusters
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 I'll explain what they do. The following screenshot shows a listing of the area of the code you are going to change:
You will edit your program by...