zhouhang shao
/
test
test
main.cpp
- Committer:
- szh66
- Date:
- 2017-05-06
- Revision:
- 2:b78dfa2afe92
- Parent:
- 1:11970e541ecf
- Child:
- 3:34a763e93423
File content as of revision 2:b78dfa2afe92:
/** * This is simple program to test usart with IR sensors. */ #include "mbed.h" #include "IRSensor.h" //#include "encoder.h" #include "motor.h" Serial serial (PA_9, PA_10); //IRSensor testIR_RIGHT(PB_0, PA_4); //emmiter and receiver right most sensor // IRSensor testIR_LEFT(PA_8, PC_5); //emmiter and receiver left most sensor DigitalOut testLed(PB_12); DigitalOut testLed2(PB_13); DigitalOut testLed3(PB_14); DigitalOut testLed4(PB_15); AnalogIn Ain(PA_3); //Motor leftMotor(PB_7, PB_6); Motor rightMotor(PB_9, PB_8); //Encoder leftEncoder(PC_9, PC_8); int main () { serial.printf ("Start Program\n"); //leftMotor = 0.1f; while (1) { testLed2 = 1; wait (0.2); testLed2 = 0; wait (0.2); // for (int i = 0; i < 3; i++) { // leftMotor.speed(0); rightMotor.speed(-0.02f); // rightMotor.dir // leftMotor.stop(); // rightMotor.stop(); // serial.printf("Left Motor speed is at: %f \n", leftMotor.read()); serial.printf("Right Motor speed is at: %f \n", rightMotor.read()); //} serial.printf("voltage value is: %3.3f%%\r\n", Ain.read()*100.0f); //serial.printf("normalized: 0x%04X \r\n", Ain.read_u16()); if(Ain.read() < 0.67f){ testLed = 1; testLed2 = 1; testLed3 = 1; testLed4 = 1; serial.printf("voltage is in danger area, UNPLUG\r\n"); } //int dist = leftEncoder.getEncoderDistance(); //serial.printf("Encoder %d \r\n", getEncoderDistance()); } }