Buttontest

Dependencies:   mbed

Committer:
wipflhan
Date:
Mon Oct 24 16:00:53 2016 +0000
Revision:
0:c77311b3735e
kkd;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wipflhan 0:c77311b3735e 1 #include "mbed.h"
wipflhan 0:c77311b3735e 2 // LSB... ...MSB
wipflhan 0:c77311b3735e 3 // 2^0 2^1 ...........
wipflhan 0:c77311b3735e 4 BusOut lb(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1);
wipflhan 0:c77311b3735e 5 // D20 D19 D18.....
wipflhan 0:c77311b3735e 6
wipflhan 0:c77311b3735e 7 BusIn btn(P0_10, P0_15, P0_23, P1_16);
wipflhan 0:c77311b3735e 8 int main() {
wipflhan 0:c77311b3735e 9 lb = 0;//alle Leds aus
wipflhan 0:c77311b3735e 10
wipflhan 0:c77311b3735e 11 while(1)
wipflhan 0:c77311b3735e 12 {
wipflhan 0:c77311b3735e 13 if (btn & 1)//wenn sw1 gedrückt
wipflhan 0:c77311b3735e 14 lb = lb | 4;
wipflhan 0:c77311b3735e 15
wipflhan 0:c77311b3735e 16 if (btn & 2)//wenn sw2 gedrückt
wipflhan 0:c77311b3735e 17 lb = lb | 8;
wipflhan 0:c77311b3735e 18
wipflhan 0:c77311b3735e 19 if (btn & 4)//wenn sw2 gedrückt
wipflhan 0:c77311b3735e 20 lb = lb | 16;
wipflhan 0:c77311b3735e 21
wipflhan 0:c77311b3735e 22 if (btn & 8)//wenn sw2 gedrückt
wipflhan 0:c77311b3735e 23 lb = lb | 32;
wipflhan 0:c77311b3735e 24
wipflhan 0:c77311b3735e 25 wait_ms(100);
wipflhan 0:c77311b3735e 26 lb = 0;
wipflhan 0:c77311b3735e 27 wait_ms(100);
wipflhan 0:c77311b3735e 28
wipflhan 0:c77311b3735e 29 }
wipflhan 0:c77311b3735e 30 }