
Bertl Robot with fiunctions
Revision 6:be710baf53ec, committed 2015-01-22
- Comitter:
- bulmecisco
- Date:
- Thu Jan 22 13:44:59 2015 +0000
- Parent:
- 5:7b091d085c70
- Child:
- 7:cb6947e1f1d3
- Commit message:
- MoveMeasure Bug fixed.
Changed in this revision
config.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/config.h Thu Jan 15 10:18:16 2015 +0000 +++ b/config.h Thu Jan 22 13:44:59 2015 +0000 @@ -1,9 +1,9 @@ /*********************************** -name: config.h v0.1 +name: config.h v0.2 author: PE HTL BULME email: pe@bulme.at description: - Constants and wiring for ur_Karel + Constants and wiring for ur_Bertl ***********************************/ @@ -15,13 +15,6 @@ #define DEBUG 0 -#if defined(DEBUG) && DEBUG > 0 - #define DEBUG_PRINT(fmt, args...) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, \ - __FILE__, __LINE__, __func__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */ -#endif - const int BTN_FLL = 0x80; // button front left outer const int BTN_FL = 0x04; // button front left const int BTN_FM = 0x01; // button front middle @@ -58,12 +51,19 @@ DigitalOut MotorL_REVERSE(P1_0); DigitalOut MotorR_EN(p36); // wiring motor right -DigitalOut MotorR_FORWARD(P1_3); -DigitalOut MotorR_REVERSE(P1_4); +DigitalOut MotorR_FORWARD(P1_4); +DigitalOut MotorR_REVERSE(P1_3); I2C i2c(p28,p27); BusIn linesensor(p18, p16, p19, p17); DigitalIn SensorL(P1_12); // motor sensor left DigitalIn SensorR(P1_13); // motor sensor right +#if defined(DEBUG) && DEBUG > 0 + #define DEBUG_PRINT(fmt, args...) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, \ + __FILE__, __LINE__, __func__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */ +#endif + #endif \ No newline at end of file
--- a/main.cpp Thu Jan 15 10:18:16 2015 +0000 +++ b/main.cpp Thu Jan 22 13:44:59 2015 +0000 @@ -1,5 +1,5 @@ /*********************************** -* name: func_Bertl v 0.2 +* name: func_Bertl v 0.3 * author: PE HTL BULME * email: pe@bulme.at * description: @@ -9,6 +9,7 @@ #include "mbed.h" #include "config.h" +bool Start(); void ShutOff(); void Move(); bool FrontIsClear(); @@ -23,19 +24,23 @@ void MoveMore(int anzahl); void Back(); bool WaitUntilButtonPressed(); -bool Start(); + +// Eigene Funktionsdefinitionen hier + // ************* Hauptprogramm ************ int main() { - while(!Start()) {} // wait to start + // while(!Start()) {} // wait to start wait_ms(200); Move(); TurnLeft(); Move(); + TurnLeftTicks(2000); // Anzahl der MotorSensorwerte + ShutOff(); return 0; } @@ -102,14 +107,21 @@ return wert; } -bool MoveMeasure(int& left, int& right) +/* +use in main(): + int left=0, right=0; + + MoveMeasure(1000, left, right); + pc.printf("\r\nleft= %d right= %d\r\n", left, right); +*/ +bool MoveMeasure(int time, int& left, int& right) { int count=0; //, left=0, right=0; MotorR_EN=MotorL_EN=1; MotorR_FORWARD = MotorL_FORWARD = 1; - while(count<1000) { + while(count<time) { MotorR_FORWARD = MotorL_FORWARD = 1; LED_D10 = SensorL; if(SensorL == 1)