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 "platform/mbed_thread.h" 00008 #include "LCD.h" 00009 00010 /* 00011 Bei mir: 00012 PC_7 Fussgänger grün 00013 PC_6 Fußgänger rot FG rot:0b01 00014 PC_5 auto1 gelb 00015 PC_4 auto1 grün 00016 PC_3 auto1 rot =>FG rot, auto1 rot :0b01 001 00017 PC_2 auto2 gelb 1 00018 PC_1 auto2 grün 0 00019 PC_0 auto2 rot 1 =>FG rot, auto1 rot, auto2 rot :0b01 001 001 00020 */ 00021 #define rotrotrot 0b01001001 //FG rot, auto1 rot, auto2 rot :0b01 001 001 00022 #define rotrotorange 0b01001101 //FG rot, auto1 rot, auto2 rotgelb :0b01 001 101 00023 #define rotrotgruen 0b01001010 //FG rot, auto1 rot, auto2 gruen :0b01 001 101 00024 #define rotrotgelb 0b01001100 //FG rot, auto1 rot, auto2 gelb :0b01 001 101 00025 #define rotorangerot 0b01101001 //FG rot, auto1 rot, auto2 rotgelb :0b01 001 101 00026 #define rotgruenrot 0b01010001 //FG rot, auto1 rot, auto2 gruen :0b01 001 101 00027 #define rotgelbrot 0b01010001 //FG rot, auto1 rot, auto2 gelb :0b01 001 101 00028 #define gruenrotgelb 0b10001001 //FG grün, auto1 rot, auto2 rot :0b01 001 001 00029 00030 00031 //1. Deklarieren global 00032 //Wir legen fest: 00033 // a) welche Anschlüsse sollen verwendet werden 00034 // b) den Namen der Anschlüsse im Programm 00035 // c) die Richtung Eingänge oder Ausgänge 00036 PortOut anzeige(PortC,0b11111111); 00037 00038 lcd mylcd; 00039 00040 AnalogIn poti(PA_0); 00041 00042 int main() 00043 { 00044 // Initialise the digital pin LED1 as an output 00045 DigitalOut led(LED1); 00046 DigitalIn taste(PA_1); 00047 taste.mode(PullDown); //bei nicht betätigt taste=0 (inaktiv) 00048 mylcd.clear(); 00049 00050 while (true) { 00051 led = !led; 00052 00053 anzeige=rotrotrot; 00054 mylcd.cursorpos(0); 00055 mylcd.printf("rot rot rot "); 00056 thread_sleep_for(poti*1000); 00057 anzeige=rotrotorange; 00058 mylcd.cursorpos(0); 00059 mylcd.printf("rot rot orange "); 00060 thread_sleep_for(poti*1000); 00061 anzeige=rotrotgruen; 00062 mylcd.cursorpos(0); 00063 mylcd.printf("rot rot gruen "); 00064 thread_sleep_for(poti*1000); 00065 anzeige=rotrotgelb; 00066 mylcd.cursorpos(0); 00067 mylcd.printf("rot rot gelb "); 00068 thread_sleep_for(poti*1000); 00069 anzeige=rotrotrot; 00070 mylcd.cursorpos(0); 00071 mylcd.printf("rot rot rot "); 00072 thread_sleep_for(poti*1000); 00073 anzeige=rotorangerot; 00074 mylcd.cursorpos(0); 00075 mylcd.printf("rot orange rot "); 00076 thread_sleep_for(poti*1000); 00077 anzeige=rotgruenrot; 00078 mylcd.cursorpos(0); 00079 mylcd.printf("rot gruen rot "); 00080 thread_sleep_for(poti*1000); 00081 anzeige=rotgelbrot; 00082 mylcd.cursorpos(0); 00083 mylcd.printf("rot gelb rot "); 00084 thread_sleep_for(poti*1000); 00085 if (taste==1) 00086 { 00087 anzeige=gruenrotgelb; 00088 mylcd.cursorpos(0); 00089 mylcd.printf("gruen rot gelb "); 00090 thread_sleep_for(poti*1000); 00091 } 00092 } 00093 }
Generated on Tue Jul 19 2022 02:48:30 by
1.7.2