![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Isme LDR ya Pot ka value print hotai, l ye p type karne pe. Kuch aur type kia to kuch nai hotai.
Dependencies: mbed
Revision 0:d5eb245951cf, committed 2016-07-01
- Comitter:
- akashlal
- Date:
- Fri Jul 01 09:24:41 2016 +0000
- Commit message:
- na
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 01 09:24:41 2016 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" + +Serial pc(USBTX,USBRX); +AnalogIn pot(PTB0); +AnalogIn ldr(PTB1); +float potf; //Declaring float value for Potentiometer reading +int poti; //Declaring int value for Potentiometer reading +float ldrf; //Declaring float value for LDR reading +int ldri; //Declaring Integer value for LDR reading +char i; + +int main() +{ + while(1) + { + if(pc.readable()) + { + i=pc.getc(); + if(i=='l') + { + ldrf=ldr.read(); + ldri=ldrf*1000; + pc.printf("LDR value is %d \n\r",ldri); + } + if(i=='p') + { + potf=pot.read(); + poti=potf*3.3*1000; + pc.printf("Pot value is %d \n\r",poti); + } + } + wait(0.5); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jul 01 09:24:41 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file