Skip to Content
Hands-On Robotics Programming with C++
book

Hands-On Robotics Programming with C++

by Dinesh Tavasalkar
March 2019
Intermediate to advanced
312 pages
7h 37m
English
Packt Publishing
Content preview from Hands-On Robotics Programming with C++

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); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming

Learn Robotics Programming

Danny Staple
C++ Reactive Programming

C++ Reactive Programming

Praseed Pai, Peter Abraham

Publisher Resources

ISBN: 9781789139006Supplemental Content