Stefan Simbürger
/
04_TINF_Interrupt
Interrupt Spielereien
Diff: main.cpp
- Revision:
- 0:9db80233bfe2
- Child:
- 1:c880c990b9b9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 02 18:28:02 2019 +0000 @@ -0,0 +1,48 @@ +#include "mbed.h" + +//Alle Buttons am Joystick definieren +DigitalIn ButtonDown(p12); +DigitalIn ButtonLeft(p13); +DigitalIn ButtonCenter(p14); +DigitalIn ButtonUp(p15); +DigitalIn ButtonRight(p16); + +BusOut myleds(LED1, LED2, LED3, LED4); +void Reset(uint8_t mask); +void bitLeft(); +/* +void print_binary(uint8_t x) { // function to print binary + for(int i=sizeof(x)<<3; i; i--) + putchar('0'+((x>>(i-1))&1)); +}*/ + +int main() +{ + uint8_t mask = 0b00001111; + + //bool lastButtonstate; + while(1) + { + if(ButtonCenter) + { + Reset(mask); + } + if(ButtonLeft) + { + bitLeft(); + } + } +} + +void Reset(uint8_t mask) +{ + myleds = mask; +} + +void bitLeft() +{ + + myleds = myleds << 1; + wait_ms(500); + +} \ No newline at end of file