-

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tunagonen
Date:
Tue May 23 13:31:17 2017 +0000
Commit message:
potentiometer check;

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	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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue May 23 13:31:17 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6
\ No newline at end of file