Lu-Hsuan Chen
/
autocar_3sensor_mbed
An auto car with 3 IR sensors.
autocar/autocar.h
- Committer:
- cudaChen
- Date:
- 2018-06-30
- Revision:
- 12:e95ed962be7a
- Child:
- 13:87cd0ae37e06
File content as of revision 12:e95ed962be7a:
#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