rohan gala
/
bigthingRec
BIGTHING
main.cpp
- Committer:
- rohangala
- Date:
- 2016-03-15
- Revision:
- 2:015a5a76bb82
- Parent:
- 1:630aef63181c
File content as of revision 2:015a5a76bb82:
#include "mbed.h" #include "stdio.h" DigitalOut myled(LED1); Serial pc(USBTX, USBRX); 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() { while(1) { if(micro.readable()) { val=(micro.getc()); if(val == 0x00) { pc.printf("%.2f ",luxm()); } if(val == 0x01) { pc.printf("%.2f ",ax*3.3); } val=0x00; wait(2); myled=1; } } }