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
--- /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);
+    }
+}