Skip to content

Commit

Permalink
simple command to avoid obstacles
Browse files Browse the repository at this point in the history
  • Loading branch information
quallenbezwinger committed Jul 15, 2018
1 parent 867c9ac commit 9d269f7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
9 changes: 0 additions & 9 deletions Software/MainApplication.ino

This file was deleted.

38 changes: 38 additions & 0 deletions Software/MainApplication/MainApplication.ino
@@ -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);
}

0 comments on commit 9d269f7

Please sign in to comment.