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 #include "mbed.h" 00002 00003 InterruptIn iiJsUp(p15); 00004 InterruptIn iiJsDown(p12); 00005 InterruptIn iiJsLeft(p13); 00006 InterruptIn iiJsRight(p16); 00007 InterruptIn iiJsCenter(p14); 00008 BusOut doLeds (LED1, LED2, LED3, LED4); 00009 00010 int Zaehler = 7; 00011 00012 void Up() 00013 { 00014 if(Zaehler <= 30) 00015 Zaehler += 1; 00016 00017 wait(0.25); 00018 } 00019 void Down() 00020 { 00021 if(Zaehler <= 30) 00022 Zaehler += 5; 00023 00024 wait(0.25); 00025 } 00026 void Left() 00027 { 00028 if(Zaehler >= -20) 00029 Zaehler -= 1; 00030 00031 wait(0.25); 00032 } 00033 void Right() 00034 { 00035 if(Zaehler >= -20) 00036 Zaehler -= 5; 00037 00038 wait(0.25); 00039 } 00040 void Zaehlerstand() 00041 { 00042 printf("Zaehlerstand = %d; Matthias Reichstam\r\n", Zaehler); 00043 wait(0.25); 00044 } 00045 00046 int main() { 00047 00048 iiJsUp.rise(&Up); 00049 iiJsDown.rise(&Down); 00050 iiJsLeft.fall(&Left); 00051 iiJsRight.fall(&Right); 00052 00053 iiJsCenter.rise(&Zaehlerstand); 00054 00055 printf("BULME: Joystick-Zaehler ; 29.01.2018 ; Matthias Reichstam\r\n"); 00056 00057 00058 00059 while(1) 00060 { 00061 if(Zaehler <= 30 && Zaehler >= -20) 00062 { 00063 doLeds = 6; 00064 } 00065 else if(Zaehler > 30) 00066 { 00067 doLeds = 12; 00068 wait(0.2); 00069 doLeds = 0; 00070 wait(0.2); 00071 } 00072 else if(Zaehler < -20) 00073 { 00074 doLeds = 3; 00075 wait(0.5); 00076 doLeds = 0; 00077 wait(0.5); 00078 } 00079 00080 00081 } 00082 }
Generated on Wed Aug 3 2022 01:19:18 by
