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,0b1111); 00013 DigitalOut warnlampe(PC_7); 00014 00015 InterruptIn TrocknenEin(PA_10); 00016 InterruptIn TrocknenAus(PA_6); 00017 DigitalIn Lichtschranke(PB_0); 00018 00019 //Zustandsdefinitionen 00020 #define Aus 0b0000 00021 #define Anlaufen 0b1110 00022 #define Betrieb 0b1111 00023 #define Abschalten 0b0111 00024 00025 void melden(const char* txt) 00026 { 00027 mylcd.clear(); 00028 mylcd.cursorpos(0); 00029 mylcd.printf("%s",txt); 00030 } 00031 00032 void trocknenEin() 00033 { 00034 if (zustand==Aus) 00035 { 00036 zustand=Anlaufen; 00037 melden("Anlauf"); 00038 } 00039 } 00040 00041 void trocknenAus() 00042 { 00043 if (zustand==Betrieb) 00044 { 00045 zustand=Abschalten; 00046 melden("Abschalten"); 00047 } 00048 } 00049 00050 void init() 00051 { 00052 TrocknenEin.mode(PullDown); 00053 TrocknenAus.mode(PullDown); 00054 Lichtschranke.mode(PullDown); 00055 00056 TrocknenEin.rise(&trocknenEin); 00057 TrocknenAus.rise(&trocknenAus); 00058 00059 zustand=Aus; 00060 } 00061 00062 int main() 00063 { 00064 init(); 00065 melden("bereit"); 00066 00067 while (true) { 00068 switch(zustand) 00069 { 00070 case Anlaufen: 00071 if (Lichtschranke==1) 00072 { 00073 zustand=Betrieb; 00074 melden("Betrieb"); 00075 } 00076 break; 00077 case Abschalten: 00078 if (Lichtschranke==0) 00079 { 00080 zustand=Aus; 00081 melden("bereit"); 00082 } 00083 break; 00084 } 00085 00086 HAL_Delay(zeit); 00087 } 00088 }
Generated on Wed Jan 25 2023 05:13:35 by
1.7.2