Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 6:28a577aa9938, committed 2018-11-26
- Comitter:
- CJS
- Date:
- Mon Nov 26 13:49:14 2018 +0000
- Parent:
- 5:54ac96f4324b
- Child:
- 7:eb51c7ed828a
- Commit message:
- -fahre_eine_acht(); -Funktion drehen()
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Nov 25 18:13:34 2018 +0000
+++ b/main.cpp Mon Nov 26 13:49:14 2018 +0000
@@ -23,6 +23,25 @@
//pc.printf("Um %d Grad gedreht",winkel);
return 1;
}
+int fahren(int speed, int direction, int time){
+ Motor_A.pulsewidth_us(speed);
+ Motor_B.pulsewidth_us(speed);
+ Direction_A=direction;
+ Direction_B=direction;
+ wait(time);
+int fahre_eine_acht(){
+ for (int i=0;i<3;i++){
+ fahren(6000,0,1);
+ drehen(90);
+ }
+ fahren(6000,0,1);
+ for (int j=0;j<3;j++){
+ fahren(6000,0,1);
+ drehen(-90);
+ }
+ fahren(6000,0,1);
+ return 1;
+}
int main() {
timer.reset();
timer.start();
@@ -30,25 +49,13 @@
Motor_A.pulsewidth_us(1);
Motor_B.period_ms(10);
Motor_B.pulsewidth_us(1);
- int dir=1;
+ //int dir=1;
Serial pc (USBTX,USBRX);
pc.baud(115200);
while(true) {
- dir=!dir;
- pc.printf("New Direction: %d %3.1f \r\n",dir,timer.read());
-
- if (dir==1){
- pc.printf("Forwaerts");
- drehen(180);
- }
- else{
- pc.printf("Rueckwaerts");
- drehen(-180);
- }
- pc.printf(" Gedreht\r\n");
- Motor_A.pulsewidth_us(0);
- Motor_B.pulsewidth_us(0);
+ pc.printf("Ich fahre eine acht %3.1f \r\n",timer.read());
+ fahre_eine_acht();
wait(0.5);
}
}