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
main.cpp
00001 /*********************************** 00002 name: BERTL_2014_TEST Motorsensoren 00003 author: Gottfried Enenkel HTL BULME 00004 email: ene@bulme.at 00005 description: 00006 Der BERTL fährt 1 sec lang VORWÄRTS! 00007 Danach steht er für 1 sec 00008 Dabei sind die Radsensoren auf die D10 bzw. D13 geschalten. 00009 Wenn an auf den Moter sieht, ist da + Zeichen 00010 immer LINKS OBEN zu sehen ! 00011 ***********************************/ 00012 #include "mbed.h" 00013 00014 // ************ DEKLARATIONEN ************** 00015 DigitalOut MotorL_EN(p34); // Motor Links = mg1 00016 DigitalOut MotorL_FORWARD(P1_1); 00017 DigitalOut MotorL_REVERSE(P1_0); 00018 00019 DigitalOut MotorR_EN(p36); //Motor Rechts = mg2 00020 DigitalOut MotorR_FORWARD(P1_3); 00021 DigitalOut MotorR_REVERSE(P1_4); 00022 00023 PwmOut mg1(P1_15); //PWM Ausgang zum Motor Links 00024 PwmOut mg2(P0_21); //PWM Ausgang zum Motor Rechts 00025 float speedy=0.3; //Motor speed 1 = Vollgas 0.3 sehr langsam 00026 // wenn kleiner als 0.2, 00027 // kann der Motor ev nicht mehr anfahren 00028 DigitalOut LED_D10(P1_8); // LED D10 und D13 definieren 00029 DigitalOut LED_D13(P1_11); // 00030 00031 DigitalIn SensorL(P1_12); // Sensor Links bei mg1 00032 DigitalIn SensorR(P1_13); // Sensor Rechts bei mg2 00033 int a; // Variable a 00034 // ************* Hauptprogramm ************ 00035 int main() { // Start Hauptprogramm 00036 mg1=mg2=speedy; 00037 MotorR_EN=MotorL_EN=(1); // Beide Motoren ENABLE 00038 00039 while (1){ 00040 a=0; //Variable a auf 0 setzen 00041 while(a<1000) { // mache solang a<1000 00042 MotorR_FORWARD = MotorL_FORWARD = 1; // Beide Motoren vorwärts EIN 00043 LED_D10 = SensorL; // LED D10 blinkt 00044 LED_D13 = SensorR; // LED D13 blinkt 00045 a++; 00046 wait_ms(1); // warte 1 mSekunde 00047 } 00048 MotorR_FORWARD = MotorL_FORWARD = 0; // Motoren AUS 00049 wait (1); // warte 1 Sekunde 00050 } // Springe zum Anfang der Schleife 00051 } 00052 00053 // ************** ENDE *************
Generated on Mon Aug 29 2022 18:04:47 by
1.7.2