Alexander Posztos
/
3BHEL_POTI
Prüfung 9.06.2016
Fork of 3BHEL_LDR1 by
main.cpp@0:4a51d86e4cbd, 2016-01-21 (annotated)
- Committer:
- PosztosAlex
- Date:
- Thu Jan 21 15:01:53 2016 +0000
- Revision:
- 0:4a51d86e4cbd
- Child:
- 1:987bbbdbcedf
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
PosztosAlex | 0:4a51d86e4cbd | 1 | #include "mbed.h" |
PosztosAlex | 0:4a51d86e4cbd | 2 | |
PosztosAlex | 0:4a51d86e4cbd | 3 | AnalogIn LDR(p16); |
PosztosAlex | 0:4a51d86e4cbd | 4 | |
PosztosAlex | 0:4a51d86e4cbd | 5 | BusOut myled(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); |
PosztosAlex | 0:4a51d86e4cbd | 6 | |
PosztosAlex | 0:4a51d86e4cbd | 7 | Serial pc(USBTX,USBRX); |
PosztosAlex | 0:4a51d86e4cbd | 8 | |
PosztosAlex | 0:4a51d86e4cbd | 9 | int main() { |
PosztosAlex | 0:4a51d86e4cbd | 10 | while(1) { |
PosztosAlex | 0:4a51d86e4cbd | 11 | // myled=LDR.read_u16()/64; |
PosztosAlex | 0:4a51d86e4cbd | 12 | pc.printf("\r%u %f\n", (LDR.read_u16()/62), LDR.read()); |
PosztosAlex | 0:4a51d86e4cbd | 13 | wait(0.1); |
PosztosAlex | 0:4a51d86e4cbd | 14 | |
PosztosAlex | 0:4a51d86e4cbd | 15 | int licht= LDR.read_u16()/64; |
PosztosAlex | 0:4a51d86e4cbd | 16 | |
PosztosAlex | 0:4a51d86e4cbd | 17 | myled = 0; |
PosztosAlex | 0:4a51d86e4cbd | 18 | for(int i = 0 ;i < licht / 75; i++ ) |
PosztosAlex | 0:4a51d86e4cbd | 19 | { |
PosztosAlex | 0:4a51d86e4cbd | 20 | myled = 0b1<<i | myled ; |
PosztosAlex | 0:4a51d86e4cbd | 21 | } |
PosztosAlex | 0:4a51d86e4cbd | 22 | } |
PosztosAlex | 0:4a51d86e4cbd | 23 | } |