Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
867c9ac
commit 9d269f7
Showing
2 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <Arduino.h> | ||
#include <HCSR04.h> | ||
#include <DRV8871.h> | ||
#include <DRV8871Dual.h> | ||
|
||
//pin configuration ultrasonic front sensor | ||
#define FRONT_SENSOR_TRIGGER_PIN 12 | ||
#define FRONT_SENSOR_ECHO_PIN 13 | ||
|
||
|
||
//pin configuration motor left | ||
#define MOTOR_LEFT_IN_1 5 | ||
#define MOTOR_LEFT_IN_2 6 | ||
|
||
//pin configuration motor right | ||
#define MOTOR_RIGHT_IN_1 9 | ||
#define MOTOR_RIGHT_IN_2 10 | ||
|
||
HCSR04 frontSensor (FRONT_SENSOR_TRIGGER_PIN, FRONT_SENSOR_ECHO_PIN); | ||
DRV8871 motor_left (MOTOR_LEFT_IN_1, MOTOR_LEFT_IN_2); | ||
DRV8871 motor_right (MOTOR_RIGHT_IN_1, MOTOR_RIGHT_IN_2); | ||
DRV8871Dual motorController (&motor_left, &motor_right); | ||
|
||
void setup() { | ||
|
||
} | ||
|
||
void loop() { | ||
if (frontSensor.getObstacle(750 | ||
)) | ||
{ | ||
motorController.turn(200, motorController.TURN_RIGHT); | ||
} else { | ||
motorController.drive(200, motorController.DIRECTION_FORWARD); | ||
} | ||
|
||
delay(100); | ||
} |