-

Dependencies:   mbed

Revision:
0:350c4c9c0047
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 23 13:31:17 2017 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX); // to connect to pc
+float resistor; // defining the variable resistor 
+AnalogIn mypotentiometer(A2); // getting anolog reading from the potentiometer
+DigitalOut plus(PTE20) ; //output for 3.3 V
+DigitalOut ground(PTE22) ; //output for the ground
+
+
+int main()
+{
+    while(1) {
+        plus = 1 ; // voltage in is 3.3 V
+        ground = 0 ; // ground is 0 V
+        resistor = (mypotentiometer); // reading from the potentiometer
+        if (resistor > 0.999 ) { //in order to get an exact array from 0 to 1
+            resistor = 1 ;
+            }
+        wait(0.5); 
+        pc.printf("%f \r\n", resistor); //to print into terminal
+    }
+}
+    
+    
\ No newline at end of file