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.
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 #include "mbed.h" 00007 #include "LCD.h" 00008 00009 lcd mylcd; 00010 int zeit= 100; //Zeit in ms 00011 00012 PortOut zustand(PortC,0b111111); 00013 DigitalOut warnlampe(PC_7); 00014 00015 InterruptIn TrocknenEin(PA_10); 00016 InterruptIn TrocknenAus(PA_6); 00017 DigitalIn Lichtschranke(PB_0); 00018 00019 00020 //Zustandsdefinitionen 00021 #define Aus 0b0000 00022 #define Anlaufen 0b1110 00023 #define Betrieb 0b1111 00024 #define Abschalten 0b0111 00025 #define HaltAnlaufen 0b010000 00026 #define HaltBetrieb 0b100000 00027 #define HaltAbschalten 0b110000 00028 00029 00030 00031 00032 void melden(const char* txt) 00033 { 00034 mylcd.clear(); 00035 mylcd.cursorpos(0); 00036 mylcd.printf("%s",txt); 00037 } 00038 00039 void trocknenEin() 00040 { 00041 if (zustand==Aus) 00042 { 00043 zustand=Anlaufen; 00044 melden("Anlauf"); 00045 } 00046 } 00047 00048 void trocknenAus() 00049 { 00050 if (zustand==Betrieb) 00051 { 00052 warnlampe=0; 00053 zustand=Abschalten; 00054 melden("Abschalten"); 00055 } 00056 } 00057 00058 InterruptIn HALT(PB_4); 00059 void halt(){ 00060 switch (zustand) 00061 { 00062 case Anlaufen: zustand=HaltAnlaufen; melden("Halt"); break; 00063 case Betrieb: zustand=HaltBetrieb; melden("Halt"); break; 00064 case Abschalten: zustand=HaltAbschalten; melden("Halt"); break; 00065 } 00066 00067 00068 } 00069 int z=0; 00070 void ueberwachen() 00071 { 00072 if (z>5) warnlampe=0; 00073 else warnlampe=1; 00074 z=0; 00075 } 00076 void luefter() 00077 { 00078 z++; 00079 } 00080 InterruptIn Luefter(PA_1); 00081 void init() 00082 { 00083 Luefter.rise(&luefter); 00084 HALT.mode(PullDown); 00085 HALT.rise(&halt); 00086 TrocknenEin.mode(PullDown); 00087 TrocknenAus.mode(PullDown); 00088 Lichtschranke.mode(PullDown); 00089 00090 TrocknenEin.rise(&trocknenEin); 00091 TrocknenAus.rise(&trocknenAus); 00092 00093 zustand=Aus; 00094 } 00095 00096 00097 00098 int main() 00099 { 00100 init(); 00101 melden("bereit"); 00102 00103 while (true) { 00104 switch(zustand) 00105 { 00106 case Anlaufen: 00107 if (Lichtschranke==1) 00108 { 00109 zustand=Betrieb; 00110 melden("Betrieb"); 00111 } 00112 break; 00113 case Abschalten: 00114 if (Lichtschranke==0) 00115 { 00116 zustand=Aus; 00117 melden("bereit"); 00118 } 00119 break; 00120 case HaltAnlaufen: 00121 if (HALT==0){ 00122 zustand=Anlaufen; 00123 melden("Anlaufen"); 00124 } 00125 break; 00126 case HaltBetrieb: 00127 if (HALT==0){ 00128 zustand=Betrieb; 00129 melden("Betrieb"); 00130 } 00131 break; 00132 case HaltAbschalten: 00133 if (HALT==0){ 00134 zustand=Abschalten; 00135 melden("Abschalten"); 00136 } 00137 break; 00138 case Betrieb: ueberwachen(); 00139 break; 00140 } 00141 00142 HAL_Delay(zeit); 00143 } 00144 }
Generated on Tue Oct 25 2022 18:18:38 by
1.7.2