Dependencies:   Ping

Committer:
cudaChen
Date:
Thu Jul 19 05:17:01 2018 +0000
Revision:
0:b9d5ff825f0f
Child:
1:c7d5b9662b4f
[initial] initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cudaChen 0:b9d5ff825f0f 1 #ifndef AUTOCAR_H
cudaChen 0:b9d5ff825f0f 2 #define AUTOCAR_H
cudaChen 0:b9d5ff825f0f 3
cudaChen 0:b9d5ff825f0f 4 #include "mbed.h"
cudaChen 0:b9d5ff825f0f 5
cudaChen 0:b9d5ff825f0f 6 #include "Ping.h"
cudaChen 0:b9d5ff825f0f 7
cudaChen 0:b9d5ff825f0f 8 // used for motors
cudaChen 0:b9d5ff825f0f 9 extern DigitalOut M1_enable;
cudaChen 0:b9d5ff825f0f 10 extern DigitalOut M2_enable;
cudaChen 0:b9d5ff825f0f 11 extern DigitalOut M1_in1;
cudaChen 0:b9d5ff825f0f 12 extern DigitalOut M1_in2;
cudaChen 0:b9d5ff825f0f 13 extern DigitalOut M2_in3;
cudaChen 0:b9d5ff825f0f 14 extern DigitalOut M2_in4;
cudaChen 0:b9d5ff825f0f 15
cudaChen 0:b9d5ff825f0f 16 // used for IR sensors
cudaChen 0:b9d5ff825f0f 17 extern AnalogIn leftIR;
cudaChen 0:b9d5ff825f0f 18 extern AnalogIn middleIR;
cudaChen 0:b9d5ff825f0f 19 extern AnalogIn rightIR;
cudaChen 0:b9d5ff825f0f 20
cudaChen 0:b9d5ff825f0f 21 // used for ultrasonic sensors
cudaChen 0:b9d5ff825f0f 22 extern Ping ultrasonic;
cudaChen 0:b9d5ff825f0f 23
cudaChen 0:b9d5ff825f0f 24 // read the value of IR sensors
cudaChen 0:b9d5ff825f0f 25 void readIR(bool* left, bool* middle, bool* right, int threshold);
cudaChen 0:b9d5ff825f0f 26 int readIRValues();
cudaChen 0:b9d5ff825f0f 27 void readSensor(bool* left, bool* middle, bool* right, bool* hasObstacle, int threshold, int range);
cudaChen 0:b9d5ff825f0f 28
cudaChen 0:b9d5ff825f0f 29 long map(long x, long in_min, long in_max, long out_min, long out_max);
cudaChen 0:b9d5ff825f0f 30
cudaChen 0:b9d5ff825f0f 31 // used for controlling the direction of auto car
cudaChen 0:b9d5ff825f0f 32 void DriveSingleMotor(int m, int speed, int dir);
cudaChen 0:b9d5ff825f0f 33 void driveMotor(bool left, bool middle, bool right);
cudaChen 0:b9d5ff825f0f 34 void driveMotor(bool left, bool middle, bool right, bool hasObstacle);
cudaChen 0:b9d5ff825f0f 35 void driveMotorPID(int values, float Kp, float Ki, float Kd);
cudaChen 0:b9d5ff825f0f 36
cudaChen 0:b9d5ff825f0f 37 void init();
cudaChen 0:b9d5ff825f0f 38 void stop();
cudaChen 0:b9d5ff825f0f 39 void forward();
cudaChen 0:b9d5ff825f0f 40 void backward();
cudaChen 0:b9d5ff825f0f 41 void turnLeft();
cudaChen 0:b9d5ff825f0f 42 void turnRight();
cudaChen 0:b9d5ff825f0f 43
cudaChen 0:b9d5ff825f0f 44 #endif