Jayanth Kumar Tumuluri / Mbed 2 deprecated Lab4

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Jayanth_T
Date:
Tue Aug 06 05:31:49 2019 +0000
Parent:
0:70efaaf8fec6
Commit message:
task_2_lab_4;

Changed in this revision

task1.cpp Show diff for this revision Revisions of this file
task2.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/task1.cpp	Tue Aug 06 05:06:41 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#include "mbed.h"
-
-AnalogIn A(p20); 
-Serial pc(USBTX,USBRX); 
-int main() 
-{ 
-    while(A) 
-    { 
-      float Ain= 3.3 * A; 
-      wait(0.5);
-      pc.printf("%f\t",Ain); 
-    }
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/task2.cpp	Tue Aug 06 05:31:49 2019 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+AnalogIn ain(p20);
+BusOut dout(LED1,LED2,LED3,LED4);
+Serial pc(USBTX, USBRX);
+int main() {
+    
+    while (ain) {
+        if(ain < 0.2f)
+        {
+         
+             dout=0b0000;
+             printf("Potentiometer value %f\n\r",ain.read());
+             wait(1);
+        }
+        else if(0.4f>ain>0.2f)
+        {
+            dout=0b1000;
+            printf("Potentiometer value %f\n\r",ain.read());
+            wait(1);
+         }
+         else if(0.6f>ain>0.4f)
+        {
+         
+            dout=0b1100;
+            printf("Potentiometer value %f\n\r",ain.read());
+            wait(1);
+        }
+        else if(0.8f>ain>0.6f)
+        {
+            dout=0b1110;
+            printf("Potentiometer value %f\n\r",ain.read());
+            wait(1);
+         }
+         else if(ain>0.8f)
+        {
+         
+            dout=0b1111;
+            printf("Potentiometer value %f\n\r",ain.read());
+            wait(1);
+        }
+        
+    }
+}