In this chapter, we will build a robot with a camera attached to two servo motors. One servo will allow us to pan the camera, and the other will apply a tilt motion. In this way, we can point the camera in many different directions. In addition, we will detect and use keyboard events to move the motors in different directions and capture and save photos from the live camera stream.
We have explored the use of touch screens on mobile devices and joysticks as human interaction devices. Now we will use a keyboard to control our robot movements and camera. Keyboards are one of the oldest and most established input devices. Compared to joysticks, they come with every desktop computer and laptop and have excellent built-in support in most software, not requiring much additional effort. This makes them an excellent alternative to joysticks when we either don’t want to add additional hardware requirements or just want to simplify our device handling.