EasyManua.ls Logo

SunFounder 3in1 Kit - Page 250

Default Icon
351 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder 3in1 Kit
Code
Note:
Open the 5.obstacle_avoidance_module.ino file under the path of 3in1-kit\car_project\5.
obstacle_avoidance_module.
Or copy this code into Arduino IDE.
Or upload the code through the Arduino Web Editor.
The car will move forward once the code has been successfully uploaded. When the left infrared module detects an
obstacle, it will go backwards to the left; when the right infrared module detects an obstacle, it will go backwards to
the right; if both sides detect an obstacle, it will go backwards squarely.
How it works?
This project is based on the value of the left and right infrared obstacle avoidance modules to make the car make the
appropriate action.
1. Add the pin definition for the 2 obstacle avoidance modules, here they are set to INPUT.
...
const int rightIR = 7;
const int leftIR = 8;
(continues on next page)
246 Chapter 5. Car Projects

Related product manuals