LDR

Dependencies:   mbed

Committer:
Sandra8152
Date:
Fri Jan 15 04:35:30 2016 +0000
Revision:
0:4f98f5e4edb2
LDR

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sandra8152 0:4f98f5e4edb2 1 #include "mbed.h"
Sandra8152 0:4f98f5e4edb2 2
Sandra8152 0:4f98f5e4edb2 3 AnalogIn LDR(p16);
Sandra8152 0:4f98f5e4edb2 4 BusOut myled(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1);
Sandra8152 0:4f98f5e4edb2 5 Serial pc(USBTX, USBRX);
Sandra8152 0:4f98f5e4edb2 6
Sandra8152 0:4f98f5e4edb2 7 int main()
Sandra8152 0:4f98f5e4edb2 8 {
Sandra8152 0:4f98f5e4edb2 9 while(1)
Sandra8152 0:4f98f5e4edb2 10 {
Sandra8152 0:4f98f5e4edb2 11 myled=LDR.read_u16()/65; // 2^16 durch 10
Sandra8152 0:4f98f5e4edb2 12 pc.printf("\r%u %f\n",(LDR.read_u16()/64), LDR.read());
Sandra8152 0:4f98f5e4edb2 13 wait(0.1);
Sandra8152 0:4f98f5e4edb2 14
Sandra8152 0:4f98f5e4edb2 15 switch (zahl)
Sandra8152 0:4f98f5e4edb2 16 {
Sandra8152 0:4f98f5e4edb2 17 case 1;
Sandra8152 0:4f98f5e4edb2 18 myled = 1;
Sandra8152 0:4f98f5e4edb2 19 case 2;
Sandra8152 0:4f98f5e4edb2 20 myled = 3;
Sandra8152 0:4f98f5e4edb2 21 case 3;
Sandra8152 0:4f98f5e4edb2 22 myled = 7;
Sandra8152 0:4f98f5e4edb2 23 case 4;
Sandra8152 0:4f98f5e4edb2 24 myled = 15;
Sandra8152 0:4f98f5e4edb2 25 case 5;
Sandra8152 0:4f98f5e4edb2 26 myled = 31;
Sandra8152 0:4f98f5e4edb2 27 case 6;
Sandra8152 0:4f98f5e4edb2 28 myled = 63;
Sandra8152 0:4f98f5e4edb2 29 case 7;
Sandra8152 0:4f98f5e4edb2 30 myled = 127;
Sandra8152 0:4f98f5e4edb2 31 case 8;
Sandra8152 0:4f98f5e4edb2 32 myled = 255;
Sandra8152 0:4f98f5e4edb2 33 case 9;
Sandra8152 0:4f98f5e4edb2 34 myled = 511;
Sandra8152 0:4f98f5e4edb2 35 case 10;
Sandra8152 0:4f98f5e4edb2 36 myled = 1023;
Sandra8152 0:4f98f5e4edb2 37 case 0;
Sandra8152 0:4f98f5e4edb2 38 myled = 0;
Sandra8152 0:4f98f5e4edb2 39 }
Sandra8152 0:4f98f5e4edb2 40 }