rohan gala
/
bigthingRec
BIGTHING
Revision 2:015a5a76bb82, committed 2016-03-15
- Comitter:
- rohangala
- Date:
- Tue Mar 15 09:40:07 2016 +0000
- Parent:
- 1:630aef63181c
- Commit message:
- pp without int;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Mar 15 07:39:10 2016 +0000 +++ b/main.cpp Tue Mar 15 09:40:07 2016 +0000 @@ -2,22 +2,42 @@ #include "stdio.h" DigitalOut myled(LED1); Serial pc(USBTX, USBRX); -Serial micro(PTA2, PTA1); // tx, rx +Serial micro(PTE0, PTE1); // tx, rx char buff[]={'\0'}; +AnalogIn ax(PTC1); + +float luxm(void) +{ +AnalogIn ain(PTC2); + +float vr=0,lr=0; + +float vol[12]={0.36,0.61,0.8,0.9,1.23,1.45,1.81,2.06,2.62,2.81,3.02,3.25}; +float lux[12]={27000,20000,16000,11000,4000,1500,833,578,201,104,40,23}; + +int i; +float m=0; + +vr=ain*3.3; +for(i=0; vr> vol[i];i++); +m = ((lux[i]-lux[i+1])/(vol[i]-vol[i+1])); +lr=lux[i+1]+(m*(vr-(vol[i+1]))); + +return lr; +} + + + uint8_t val; int main() -{myled = 1; - // wait(3); - +{ while(1) { if(micro.readable()) { - - myled = 0; val=(micro.getc()); @@ -25,15 +45,15 @@ { + pc.printf("%.2f ",luxm()); - pc.putc(0x04); } if(val == 0x01) { - pc.putc(0x09); + pc.printf("%.2f ",ax*3.3); } val=0x00;