








{"id":288,"date":"2020-10-20T03:48:33","date_gmt":"2020-10-20T03:48:33","guid":{"rendered":"https:\/\/osoyoo.info\/?p=288"},"modified":"2020-10-20T07:15:53","modified_gmt":"2020-10-20T07:15:53","slug":"arduino-basic-lesson-28-obstacle-avoidance-robot-car","status":"publish","type":"post","link":"https:\/\/osoyoo.info\/index.php\/2020\/10\/20\/arduino-basic-lesson-28-obstacle-avoidance-robot-car\/","title":{"rendered":"Hardware Programming with Arduino IDE &#8211; Lesson 28 : Obstacle Avoidance Robot Car"},"content":{"rendered":"<p><a href=\"https:\/\/osoyoo.info\/index.php\/2020\/10\/20\/arduino-basic-lesson-27-ir-remote-control-robot-car\/\"><img loading=\"lazy\" class=\"alignnone\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Previous.png\" alt=\"\" width=\"206\" height=\"59\" \/><\/a> <a href=\"https:\/\/osoyoo.info\/index.php\/2020\/10\/11\/arduino-basic-tutorial-directory\/\"><img loading=\"lazy\" class=\"alignnone\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Tutorial.png\" alt=\"\" width=\"206\" height=\"59\" \/><\/a> <a href=\"https:\/\/osoyoo.info\/index.php\/2020\/10\/20\/arduino-basic-lesson-29-robot-car-line-tracking\/\"><img loading=\"lazy\" class=\"alignright\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Next.png\" alt=\"\" width=\"206\" height=\"59\" \/><\/a><\/p>\n<div align=\"center\"><img loading=\"lazy\" class=\"aligncenter size-full\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Authorized_Online_Retailers.png\" width=\"1150\" height=\"56\" \/><\/div>\n<div align=\"center\"><\/div>\n<div align=\"center\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td>Buy from US<\/td>\n<td>Buy from UK<\/td>\n<td>Buy from DE<\/td>\n<td>Buy from IT<\/td>\n<td>Buy from FR<\/td>\n<td>Buy from ES<\/td>\n<td>Buy from JP<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/www.amazon.com\/OSOYOO-Programming-Controlled-Mechanical-Educational\/dp\/B08163QYLB\/ref=as_li_ss_tl?keywords=arduino+kit&amp;qid=1577086035&amp;sr=8-10&amp;&amp;linkCode=ll1&amp;tag=osoyoo-20&amp;linkId=03d3fc4c0ddacde6e72868e74f51df64&amp;language=en_US\"><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/icon\/us_buy_now.png\" width=\"150\" height=\"30\" \/><\/a><\/td>\n<td><a href=\"https:\/\/www.amazon.co.uk\/dp\/B08163QYLB\/ref=as_li_ss_tl?ref_=nav_signin&amp;&amp;linkCode=ll1&amp;tag=osoyoo-21&amp;linkId=100d3e2260cacec7910ba471d1a14e4a&amp;language=en_GB\"><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/icon\/uk_buy_now.png\" width=\"150\" height=\"30\" \/><\/a><\/td>\n<td><a href=\"https:\/\/www.amazon.de\/dp\/B08163QYLB\/ref=as_li_ss_tl?ref=myi_title_dp&amp;linkCode=ll1&amp;tag=osoyoo05-21&amp;linkId=b5b682a9eb223e4fb00c18bfa0604e05&amp;language=de_DE\"><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/icon\/de_buy_now.png\" width=\"150\" height=\"30\" \/><\/a><\/td>\n<td><a href=\"https:\/\/www.amazon.it\/dp\/B08163QYLB\/ref=as_li_ss_tl?ref=myi_title_dp&amp;linkCode=ll1&amp;tag=osoyoo01-21&amp;linkId=7e28023235665dc16687428f095136d7&amp;language=it_IT\"><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/icon\/it_buy_now.png\" width=\"150\" height=\"30\" \/><\/a><\/td>\n<td><a href=\"https:\/\/www.amazon.fr\/dp\/B08163QYLB\/ref=as_li_ss_tl?ref=myi_title_dp&amp;ref_=nav_ya_signin&amp;_encoding=UTF8&amp;&amp;linkCode=ll1&amp;tag=osoyoo0b-21&amp;linkId=b64d046d9d9dcfd1a21d58d068b88062&amp;language=fr_FR\"><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/icon\/fr_buy_now.png\" width=\"150\" height=\"30\" \/><\/a><\/td>\n<td><a href=\"https:\/\/www.amazon.es\/dp\/B08163QYLB\/ref=as_li_ss_tl?ref=nav_signin&amp;ref_=nav_ya_signin&amp;_encoding=UTF8&amp;&amp;&amp;linkCode=ll1&amp;tag=osoyoo04-21&amp;linkId=f06db7c77f513ff8707cead3b285b17e&amp;language=es_ES\"><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/icon\/es_buy_now.png\" width=\"150\" height=\"30\" \/><\/a><\/td>\n<td><a href=\"https:\/\/www.amazon.co.jp\/dp\/B08168W3D5?ref=myi_title_dp\"><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/icon\/jp_buy_now.png\" width=\"150\" height=\"30\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><img loading=\"lazy\" class=\"left aligncenter\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/objective.png\" alt=\"\" width=\"1150\" height=\"56\" \/><\/p>\n<p>In this project, we will use obstacle sensor(ultrasonic distance detector) to detect obstacles ,avoid collision and auto-drive.<\/p>\n<p><img loading=\"lazy\" class=\"left aligncenter\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Parts-&amp;-Devices-min.png\" alt=\"\" width=\"1150\" height=\"56\" \/><\/p>\n<ul>\n<li>OSOYOO UNO Board (Fully compatible with Arduino UNO rev.3) x 1<\/li>\n<li>OSOYOO Magic I\/O Shield for Arduino x1<\/li>\n<li>OSOYOO IR Sensor Module x1<\/li>\n<li>OSOYOO Servo Motor x1<\/li>\n<li>OSOYOO Ultrasonic Sensor Module x1<\/li>\n<li>OSOYOO 3-Pin PNP Cable 10cm x 6<\/li>\n<li>OSOYOO 3-Pin PNP Cable 20cm x 1<\/li>\n<li>OSOYOO 4-Pin PNP Cable 20cm x 1<\/li>\n<li>Acrylic Platform x1<\/li>\n<li>Transmission Motor with 2 Wheels<\/li>\n<li>USB Cable<\/li>\n<\/ul>\n<p><img loading=\"lazy\" class=\"left aligncenter\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/how_to_make.png\" alt=\"\" width=\"1150\" height=\"56\" \/><\/p>\n<p>Install the smart car basic frame work as per\u00a0 Lesson 21\uff0c If you have already completed installation in Lesson 21 , just keep it as is.<\/p>\n<p><strong>Step 1:<\/strong>Remove screws on copper pillars and install servo motor at the front of car chassis with 2pcs M2.2*8 Self Tapping Screws.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/lesson23\/step1.png\" width=\"1000\" height=\"436\" \/><\/p>\n<p><strong>Step 2:<\/strong>Install bracket (from servo motor package) on mount holder for Ultrasonic Module with 2pcs M1.5*4 Self Tapping Screws<br \/>\n<img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/lesson23\/step2.png\" width=\"1000\" height=\"400\" \/><\/p>\n<p><strong>Step 3:<\/strong> Install Ultrasonic Module to mount holder with 4pcs M1.4*8 screw and M1.4 nuts.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/lesson23\/step3.png\" width=\"1000\" height=\"400\" \/><\/p>\n<p><strong>Step 4:<\/strong> Install mount holder for Ultrasonic Module on servo motor with M2*4 Self Tapping screw.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/lesson23\/step4.png\" width=\"1000\" height=\"436\" \/><\/p>\n<p><strong>Step 5:<\/strong>If you have already completed wire connection installation in Lesson 21 , just keep it as is.<\/p>\n<p>Then Connect SG90 servo motor to OSOYOO to the D3 port of the Magic I\/O shield as following graph.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/lesson23\/connection4-servo.png\" width=\"1000\" height=\"580\" \/><\/p>\n<p><strong>Step 6:<\/strong>Then connect the Ultrasonic module sensor to the D7D8 port of the Magic I\/O shield with a 4-pin PNP cable as below:<br \/>\n<img loading=\"lazy\" class=\"alignnone size-large\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/lesson23\/connection5-ultrasonic.png\" width=\"1000\" height=\"580\" \/><\/p>\n<p><img loading=\"lazy\" class=\"left aligncenter\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/how_to_code.png\" alt=\"\" width=\"1150\" height=\"56\" \/><\/p>\n<h4><span style=\"color: #ff0000;\"><strong>Notice: Shut off your battery or Unplug your power adapter when upload sketch code to Arduino.<\/strong><\/span><\/h4>\n<p>After above installations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled <strong>PWR<\/strong>) should turn on.<\/p>\n<p>Now you can download the sketch code directly from following link\uff1a<\/p>\n<h3><a href=\"https:\/\/osoyoo.info\/upload\/lesson28.zip\"><strong>https:\/\/osoyoo.info\/upload\/lesson28.zip<\/strong><\/a><\/h3>\n<p>Unzip the file, double click the lesson28.ino to open Arduino IDE and upload the code to the Arduino IDE<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"left aligncenter\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/how_to_play.png\" alt=\"\" width=\"1150\" height=\"56\" \/><\/p>\n<p><strong>Adjust the Ultrasonic Sensor direction:<\/strong><br \/>\nAfter the code is loaded into robot car,\u00a0 unplug the USB cable from the UNO board and turn on the power switch on the Magic I\/O board. Then the ultrasonic sensor will rotate to face the straight forward direction for 2 seconds. If the Ultrasonic sensor is not facing the front position, please turn off the power. Please use a screw driver to adjust the ultrasonic sensor direction and make it facing straight ahead , then turn on the power again\u00a0 and during the early 5 seconds, the sensor should be facing front direction.<\/p>\n<p>After the 5 seconds , the robot car will start to drive\u00a0 and change direction to avoid obstacles automatically.<\/p>\n<div align=\"center\"><iframe src=\"https:\/\/www.youtube.com\/embed\/SyeAWvnZ530\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" data-mce-type=\"bookmark\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><\/div>\n<p><a href=\"https:\/\/osoyoo.info\/index.php\/2020\/10\/20\/arduino-basic-lesson-27-ir-remote-control-robot-car\/\"><img loading=\"lazy\" class=\"alignnone\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Previous.png\" alt=\"\" width=\"206\" height=\"59\" \/><\/a> <a href=\"https:\/\/osoyoo.info\/index.php\/2020\/10\/11\/arduino-basic-tutorial-directory\/\"><img loading=\"lazy\" class=\"alignnone\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Tutorial.png\" alt=\"\" width=\"206\" height=\"59\" \/><\/a> <a href=\"https:\/\/osoyoo.info\/index.php\/2020\/10\/20\/arduino-basic-lesson-29-robot-car-line-tracking\/\"><img loading=\"lazy\" class=\"alignright\" src=\"https:\/\/osoyoo.com\/picture\/Arduino_Graphical_Programming_Kit\/Next.png\" alt=\"\" width=\"206\" height=\"59\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP In this project, we will use obstacle sensor(ultrasonic distance detector) to detect obstacles ,avoid collision and auto-drive. OSOYOO UNO Board (Fully compatible with Arduino UNO rev.3) x 1 OSOYOO Magic I\/O Shield for Arduino [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":290,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/posts\/288"}],"collection":[{"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/comments?post=288"}],"version-history":[{"count":6,"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/posts\/288\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/posts\/288\/revisions\/300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/media\/290"}],"wp:attachment":[{"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/media?parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/categories?post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osoyoo.info\/index.php\/wp-json\/wp\/v2\/tags?post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}