The programming logic

In the Facetrackingrobot program, wiringPi pins 0, 2, and 3 are set as output pins:

 pinMode(0,OUTPUT); pinMode(2,OUTPUT); pinMode(3,OUTPUT);

From the face-detection program, you may have noticed that the face-tracking process is very slow. Therefore, when you move your face to the left or right, you have to make sure that the motors don't move too fast. To reduce the speed of the motor, we will use the softPwm.h library, which we also used in Chapter 2, Implementing Blink with wiringPi:

  1. From the softPwm.h library, use the softPwmCreate function to declare the four motor pins (24, 27, 25, and 28):
softPwmCreate(24,0,100); //pin 24 is left Motor pinsoftPwmCreate(27,0,100); //pin 27 is left motor pin softPwmCreate(25,0,100); ...

Get Hands-On Robotics Programming with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.