Handreichung TI3
Embed:
(wiki syntax)
Show/hide line numbers
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 "platform/mbed_thread.h" 00008 #include "LCD.h" 00009 00010 lcd mylcd; 00011 00012 int Zustand=0; 00013 int x=0; 00014 00015 InterruptIn A(PB_1); //DT 00016 InterruptIn B(PB_0); //CLJ 00017 PortIn drehgeber(PortB,0b11); 00018 00019 void Arise() 00020 { 00021 switch(Zustand) 00022 { 00023 case 0: Zustand=1; 00024 x++; 00025 break; 00026 case 3: Zustand=2; 00027 x--; 00028 break; 00029 } 00030 } 00031 00032 void Afall() 00033 { 00034 switch(Zustand) 00035 { 00036 case 1: Zustand=0; 00037 x--; 00038 break; 00039 case 2: Zustand=3; 00040 x++; 00041 break; 00042 } 00043 } 00044 00045 void Brise() 00046 { 00047 switch(Zustand) 00048 { 00049 case 1: Zustand=2; 00050 x++; 00051 break; 00052 case 0: Zustand=3; 00053 x--; 00054 break; 00055 } 00056 } 00057 00058 void Bfall() 00059 { 00060 switch(Zustand) 00061 { 00062 case 2: Zustand=1; 00063 x--; 00064 break; 00065 case 3: Zustand=0; 00066 x++; 00067 break; 00068 } 00069 } 00070 00071 00072 00073 int main() 00074 { 00075 A.rise(&Arise); 00076 A.fall(&Afall); 00077 A.enable_irq(); 00078 B.rise(&Brise); 00079 B.fall(&Bfall); 00080 B.enable_irq(); 00081 Zustand=drehgeber; 00082 00083 00084 mylcd.clear(); 00085 00086 while (true) { 00087 00088 00089 mylcd.cursorpos(0); 00090 mylcd.printf("Position %d ",x); 00091 00092 00093 } 00094 }
Generated on Mon Jul 18 2022 07:46:15 by
1.7.2