Geschwindigkeit kann nun geändert werden

Dependencies:   mbed

Committer:
PatrickMarterer
Date:
Wed May 25 07:57:26 2016 +0000
Revision:
6:dc02e3e244e6
Parent:
5:f6930387a28e
Child:
7:006fee3cc64e
Verbesserung

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Enenkel 0:a8a0195ed7dc 1 /***********************************
Enenkel 3:acd2b6fdcd7f 2 name: BERTL_16_MOTOR_TEST 8.1.2016
Enenkel 1:0f7c167a4f97 3 author: Gottfried Enenkel HTL BULME
Enenkel 1:0f7c167a4f97 4 email: ene@bulme.at
Enenkel 0:a8a0195ed7dc 5 description:
PatrickMarterer 4:2bf2ab6a1163 6 Der BERTL fährt 1 sec lang VORWÄRTS!
Enenkel 1:0f7c167a4f97 7 Danach steht er für 1 sec
PatrickMarterer 4:2bf2ab6a1163 8
PatrickMarterer 4:2bf2ab6a1163 9 Wenn der Motor richtig eingebaut ist,
Enenkel 1:0f7c167a4f97 10 steht über dem Linken Anschluß ein PLUS
PatrickMarterer 4:2bf2ab6a1163 11 Wenn sich der BERTL dreht, ist ein Motor verkehrt eingebaut.
PatrickMarterer 4:2bf2ab6a1163 12
Enenkel 1:0f7c167a4f97 13 ***********************************/
Enenkel 1:0f7c167a4f97 14 #include "mbed.h"
Enenkel 1:0f7c167a4f97 15
Enenkel 1:0f7c167a4f97 16 // ************ DEKLARATIONEN **************
PatrickMarterer 5:f6930387a28e 17 DigitalOut Von (P2_13);
Enenkel 1:0f7c167a4f97 18
PatrickMarterer 5:f6930387a28e 19 PwmOut MotorL (P1_19);
PatrickMarterer 5:f6930387a28e 20 DigitalOut MotorL_EN(P1_19);
PatrickMarterer 5:f6930387a28e 21 DigitalOut MotorL_FORWARD(P2_15);
PatrickMarterer 5:f6930387a28e 22 DigitalOut MotorL_REVERSE(P2_14);
PatrickMarterer 5:f6930387a28e 23
PatrickMarterer 5:f6930387a28e 24 PwmOut MotorR (P2_19);
PatrickMarterer 5:f6930387a28e 25 DigitalOut MotorR_EN(P2_19);
PatrickMarterer 5:f6930387a28e 26 DigitalOut MotorR_FORWARD(P2_20);
PatrickMarterer 4:2bf2ab6a1163 27 DigitalOut MotorR_REVERSE(P2_21);
PatrickMarterer 4:2bf2ab6a1163 28
Enenkel 0:a8a0195ed7dc 29
Enenkel 1:0f7c167a4f97 30 // ************* Hauptprogramm ************
PatrickMarterer 4:2bf2ab6a1163 31 int main()
PatrickMarterer 4:2bf2ab6a1163 32 {
PatrickMarterer 4:2bf2ab6a1163 33 DigitalOut LED1 (P1_10);
PatrickMarterer 4:2bf2ab6a1163 34 DigitalOut LED2 (P1_11);
PatrickMarterer 4:2bf2ab6a1163 35 DigitalOut LED3 (P1_12);
PatrickMarterer 4:2bf2ab6a1163 36 DigitalOut LED4 (P1_12);
PatrickMarterer 4:2bf2ab6a1163 37 DigitalOut LED5 (P1_13);
PatrickMarterer 4:2bf2ab6a1163 38 DigitalOut LED6 (P1_14);
PatrickMarterer 4:2bf2ab6a1163 39 DigitalOut LED7 (P1_15);
PatrickMarterer 4:2bf2ab6a1163 40 DigitalOut LED8 (P1_16);
PatrickMarterer 4:2bf2ab6a1163 41 DigitalOut LED9 (P1_17);
PatrickMarterer 4:2bf2ab6a1163 42 DigitalOut LED10 (P1_18);
PatrickMarterer 4:2bf2ab6a1163 43 DigitalOut LED11 (P2_16);
PatrickMarterer 4:2bf2ab6a1163 44 DigitalOut LED12 (P1_20);
PatrickMarterer 4:2bf2ab6a1163 45 DigitalOut LED13 (P1_21);
PatrickMarterer 4:2bf2ab6a1163 46 DigitalOut LED20 (P1_5);
PatrickMarterer 4:2bf2ab6a1163 47 DigitalOut LED24 (P1_5);
PatrickMarterer 4:2bf2ab6a1163 48 DigitalOut LED25 (P1_6);
PatrickMarterer 4:2bf2ab6a1163 49 DigitalOut TA1 (P1_23);
PatrickMarterer 4:2bf2ab6a1163 50 Von=1;
PatrickMarterer 4:2bf2ab6a1163 51 MotorR_EN=MotorL_EN=1;
PatrickMarterer 5:f6930387a28e 52 //int a;
PatrickMarterer 5:f6930387a28e 53 //a=0;
PatrickMarterer 5:f6930387a28e 54 while(1) {
PatrickMarterer 6:dc02e3e244e6 55 MotorL = 0.75f; //Bereich zwischen 1 und 0 stellt dei Geschwindigkeit ein.
PatrickMarterer 6:dc02e3e244e6 56 MotorR = 1f; //Bereich zwischen 1 und 0 stellt dei Geschwindigkeit ein.
PatrickMarterer 5:f6930387a28e 57 if(TA1==1)
PatrickMarterer 5:f6930387a28e 58 {
PatrickMarterer 5:f6930387a28e 59 MotorL_REVERSE=1;
PatrickMarterer 5:f6930387a28e 60 MotorR_REVERSE=1;
PatrickMarterer 5:f6930387a28e 61 wait(2.0);
PatrickMarterer 5:f6930387a28e 62 MotorR_REVERSE=0;
PatrickMarterer 5:f6930387a28e 63 MotorL_REVERSE=0;
PatrickMarterer 5:f6930387a28e 64 wait (0.5);
PatrickMarterer 5:f6930387a28e 65
PatrickMarterer 5:f6930387a28e 66 MotorR_REVERSE=1;
PatrickMarterer 5:f6930387a28e 67 MotorL_FORWARD=1;
PatrickMarterer 5:f6930387a28e 68 wait (0.25);
PatrickMarterer 5:f6930387a28e 69 MotorR_REVERSE=0;
PatrickMarterer 5:f6930387a28e 70 MotorL_FORWARD=0;
PatrickMarterer 5:f6930387a28e 71 }
PatrickMarterer 4:2bf2ab6a1163 72
PatrickMarterer 5:f6930387a28e 73 else
PatrickMarterer 5:f6930387a28e 74 {
PatrickMarterer 5:f6930387a28e 75 int b;
PatrickMarterer 5:f6930387a28e 76 //int c;
PatrickMarterer 5:f6930387a28e 77 int d;
PatrickMarterer 5:f6930387a28e 78
PatrickMarterer 5:f6930387a28e 79 LED1=LED2=LED4=LED5=LED6=LED7=LED8=LED9=LED10=LED11=LED12=LED13=LED20=LED24=1;
PatrickMarterer 5:f6930387a28e 80 LED1=LED4=0;
PatrickMarterer 5:f6930387a28e 81 LED20=LED24=0;
PatrickMarterer 5:f6930387a28e 82 MotorL_FORWARD = 1;
PatrickMarterer 5:f6930387a28e 83 MotorR_FORWARD = 1;
PatrickMarterer 5:f6930387a28e 84
PatrickMarterer 5:f6930387a28e 85 wait (7.0);
PatrickMarterer 5:f6930387a28e 86
PatrickMarterer 5:f6930387a28e 87 MotorL_FORWARD = 0;
PatrickMarterer 5:f6930387a28e 88 MotorR_FORWARD = 0;
PatrickMarterer 5:f6930387a28e 89
PatrickMarterer 5:f6930387a28e 90 LED1=LED4=1;
PatrickMarterer 5:f6930387a28e 91 LED7=LED9=0;
PatrickMarterer 5:f6930387a28e 92 b=0;
PatrickMarterer 5:f6930387a28e 93 while (b<2) {
PatrickMarterer 5:f6930387a28e 94 LED8=0;
PatrickMarterer 5:f6930387a28e 95 LED5=0;
PatrickMarterer 5:f6930387a28e 96 wait (0.5);
PatrickMarterer 5:f6930387a28e 97 LED5=1;
PatrickMarterer 5:f6930387a28e 98 LED8=1;
PatrickMarterer 5:f6930387a28e 99 wait (0.5);
PatrickMarterer 5:f6930387a28e 100 b=b++;
PatrickMarterer 5:f6930387a28e 101 }
PatrickMarterer 5:f6930387a28e 102
PatrickMarterer 5:f6930387a28e 103
PatrickMarterer 5:f6930387a28e 104
PatrickMarterer 5:f6930387a28e 105 MotorL_FORWARD =1;
PatrickMarterer 5:f6930387a28e 106 MotorR_REVERSE =1;
PatrickMarterer 5:f6930387a28e 107 wait (0.25);
PatrickMarterer 5:f6930387a28e 108 MotorL_FORWARD = 0;
PatrickMarterer 5:f6930387a28e 109 MotorR_REVERSE = 0;
PatrickMarterer 5:f6930387a28e 110 wait (2.0);
PatrickMarterer 5:f6930387a28e 111 LED7=LED9= 1;
PatrickMarterer 5:f6930387a28e 112
PatrickMarterer 5:f6930387a28e 113 LED1=LED4=0;
PatrickMarterer 5:f6930387a28e 114 MotorL_FORWARD=1;
PatrickMarterer 5:f6930387a28e 115 MotorR_FORWARD=1;
PatrickMarterer 5:f6930387a28e 116 wait (4.0);
PatrickMarterer 5:f6930387a28e 117 MotorL_FORWARD=0;
PatrickMarterer 5:f6930387a28e 118 MotorR_FORWARD=0;
PatrickMarterer 5:f6930387a28e 119 wait (0.0);
PatrickMarterer 5:f6930387a28e 120 LED1=LED4=1;
PatrickMarterer 5:f6930387a28e 121
PatrickMarterer 5:f6930387a28e 122 LED7=LED9=0;
PatrickMarterer 5:f6930387a28e 123
PatrickMarterer 5:f6930387a28e 124 d=0;
PatrickMarterer 5:f6930387a28e 125 while(d<2) {
PatrickMarterer 5:f6930387a28e 126 LED8=LED5=0;
PatrickMarterer 5:f6930387a28e 127 wait (0.5);
PatrickMarterer 5:f6930387a28e 128 LED8=LED5=1;
PatrickMarterer 5:f6930387a28e 129 wait (0.5);
PatrickMarterer 5:f6930387a28e 130 d=d++;
PatrickMarterer 5:f6930387a28e 131 }
PatrickMarterer 5:f6930387a28e 132 MotorL_FORWARD=1;
PatrickMarterer 5:f6930387a28e 133 MotorR_REVERSE=1;
PatrickMarterer 5:f6930387a28e 134 wait (0.25);
PatrickMarterer 5:f6930387a28e 135 MotorL_FORWARD=0;
PatrickMarterer 5:f6930387a28e 136 MotorR_REVERSE=0;
PatrickMarterer 4:2bf2ab6a1163 137 wait (0.5);
PatrickMarterer 5:f6930387a28e 138 LED7=LED9=1;
PatrickMarterer 5:f6930387a28e 139 LED1=LED4=LED20=LED24=0;
PatrickMarterer 4:2bf2ab6a1163 140 }
PatrickMarterer 4:2bf2ab6a1163 141
PatrickMarterer 5:f6930387a28e 142
PatrickMarterer 4:2bf2ab6a1163 143
PatrickMarterer 5:f6930387a28e 144 //a=a++;
Enenkel 1:0f7c167a4f97 145
PatrickMarterer 4:2bf2ab6a1163 146 }
PatrickMarterer 4:2bf2ab6a1163 147 }
PatrickMarterer 4:2bf2ab6a1163 148 // ************** ENDE *************
Enenkel 1:0f7c167a4f97 149