Christian Weiß
/
TINF_Test
TINF_Test
Diff: main.cpp
- Revision:
- 0:6c46858f4ced
diff -r 000000000000 -r 6c46858f4ced main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 15 18:10:05 2018 +0000 @@ -0,0 +1,84 @@ +#include "mbed.h" + + +int zaehler = 7; + +InterruptIn JsUp(p15); +InterruptIn JsDown(p12); +InterruptIn JsLeft(p13); +InterruptIn JsRight(p16); +InterruptIn JsCenter(p14); +BusOut myLed(LED1, LED2, LED3, LED4); + + +int main() { + + JsUp.rise(&plus1); + JsDown.rise(&plus5); + JsLeft.fall(&minus1); + JsRight.fall(&minus5); + + JsCenter.rise(&Zaehlerstand); + + printf("BULME: Joystick-Zaehler ++++++ 29.01.2018 ++++++ Christian Weiss"); + + + + while(1) + { + if(zaehler <= 30 && zaehler >= -20) + { + myLed = 6; + } + else if(zaehler > 30) + { + myLed = 12; + wait(0.2); + myLed = 0; + wait(0.2); + } + else if(zaehler < -20) + { + myLed = 3; + wait(0.5); + myLed = 0; + wait(0.5); + } + + + } +} + +void plus1() +{ + if(zaehler <= 30) + zaehler += 1; + + wait(0.25); +} +void plus5() +{ + if(zaehler <= 30) + zaehler += 5; + + wait(0.25); +} +void minus1() +{ + if(zaehler >= -20) + zaehler -= 1; + + wait(0.25); +} +void minus5() +{ + if(zaehler >= -20) + zaehler -= 5; + + wait(0.25); +} +void Zaehlerstand() +{ + printf("Zaehlerstand = %d", zaehler); + wait(0.25); +}