Craig Evans / Mbed 2 deprecated 1620_App_Board_PWM

Dependencies:   mbed

Fork of 1620_App_Board_Pots by Craig Evans

Files at this revision

API Documentation at this revision

Comitter:
eencae
Date:
Fri Feb 24 14:54:55 2017 +0000
Child:
1:30d1c1087477
Commit message:
Initial commit

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 Feb 24 14:54:55 2017 +0000
@@ -0,0 +1,31 @@
+/* ELEC1620 Application Board Example
+
+Potentiometers
+
+(c) Dr Craig A. Evans, University of Leeds, Feb 2017
+
+*/
+
+#include "mbed.h"
+
+AnalogIn pot0(p20);
+AnalogIn pot1(p19);
+AnalogIn pot2(p17);
+
+int main() {
+    
+    while(1) {
+        
+        float pot0_val = pot0.read();  // returns a float in the range 0.0 to 1.0
+        //float pot0_val = pot0;       // short-hand 
+        
+        float pot0_voltage = pot0_val*3.3f;  // multiply by 3.3 to get the voltage
+        
+        int pot0_int_val = pot0.read_u16();  // can also get int in range 0 to 65,535
+        
+        printf("Pot 0 val = %.2f [%i] (%.2f V)\n",pot0_val,pot0_int_val,pot0_voltage);
+        
+        wait(0.2);
+        
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 24 14:54:55 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f
\ No newline at end of file