Lu-Hsuan Chen
/
autocar_3sensor_mbed
An auto car with 3 IR sensors.
Diff: autocar/autocar.h
- Revision:
- 12:e95ed962be7a
- Child:
- 13:87cd0ae37e06
diff -r 3e9d4c345ebd -r e95ed962be7a autocar/autocar.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocar/autocar.h Sat Jun 30 13:08:00 2018 +0000 @@ -0,0 +1,37 @@ +#ifndef AUTOCAR_H +#define AUTOCAR_H + +#include "mbed.h" + +// used for motor +//AnalogOut M1_enable(D6); +//AnalogOut M2_enable(D5); +/*DigitalOut M1_enable(D6); +DigitalOut M2_enable(D5); +DigitalOut M1_in1(D3); +DigitalOut M1_in2(D2); +DigitalOut M2_in3(D1); +DigitalOut M2_in4(D0); +const int MOTOR_M1 = 0; +const int MOTOR_M2 = 1; +const int DIR_FORWARD = 0; +const int DIR_BACKWARD = 1; +const int PWR_STOP = 0;*/ + +// used for IR sensors +/*AnalogIn leftIR(A1); +AnalogIn middleIR(A3); +AnalogIn rightIR(A5);*/ +void readIR(bool* left, bool* middle, bool* right, int threshold); + +long map(long x, long in_min, long in_max, long out_min, long out_max); + +// used for controlling the direction of auto car +void DriveSingleMotor(int m, int speed, int dir); +void driveMotor(bool left, bool middle, bool right); +void init(); +void forward(); +void turnLeft(); +void turnRight(); + +#endif \ No newline at end of file