27 lines
585 B
C
Executable File
27 lines
585 B
C
Executable File
#include <Servo.h> //standard library for the servo
|
|
#include <NewPing.h> //for the Ultrasonic sensor function library.
|
|
|
|
//L298N motor control pins
|
|
const int LeftMotorForward = 5;
|
|
const int LeftMotorBackward = 4;
|
|
const int RightMotorForward = 6;
|
|
const int RightMotorBackward = 7;
|
|
|
|
// servo pins
|
|
const int ServoPin = 3;
|
|
|
|
//sensor pins
|
|
#define echo_pin A1
|
|
#define trig_pin A2
|
|
|
|
#define maximum_distance 200
|
|
|
|
void setupCar();
|
|
int lookRight();
|
|
int lookLeft();
|
|
int getPingDistance();
|
|
void moveStop();
|
|
void moveForward();
|
|
void moveBackward();
|
|
void turnRight();
|
|
void turnLeft(); |