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++

Programming the obstacle-avoiding robot

In this program, we will first find out the distance of a nearby object using the ultrasonic sensor. Next, we will create an if condition that monitors the distance value. If the distance goes below a certain value, we will command the robot to take a turn. Otherwise, the robot will keep moving forward. You can download the complete code called ObstacleAvoiderRobot.cpp from Chapter04 in the GitHub repository:

int main(){...for(;;){...if(distance < 7){digitalWrite(0,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,LOW);delay(500);moveCursor(firstrow);printmessage("Obstacle Status");moveCursor(secondrow);printmessage("Obstacle detected");clear();}else{digitalWrite(0,HIGH);digitalWrite(2,LOW); ...
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