Alan Sim / Mbed OS IPI_Singapore_Workshop

Fork of IPI_Singapore_Workshop by IPI Singapore Workshop

Files at this revision

API Documentation at this revision

Comitter:
alansim
Date:
Wed Nov 22 07:59:57 2017 +0000
Parent:
1:2792d77cc2cc
Commit message:
Revision Commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2792d77cc2cc -r 10f92fa42985 main.cpp
--- a/main.cpp	Wed Nov 15 08:26:34 2017 +0000
+++ b/main.cpp	Wed Nov 22 07:59:57 2017 +0000
@@ -15,10 +15,25 @@
 #include "mbed.h"
  
 // GLOBAL VARIABLES HERE
+AnalogIn pot1(A0);
+EventQueue queue;
  
 // FUNCTION DEFINITIONS HERE
+void read_potentiometer() {
+    static float potentiometer_val = 0;
+    if ((float)pot1 != potentiometer_val) {
+        potentiometer_val = (float)pot1;
+        printf("Analog Reading: %.2f\r\n",  potentiometer_val);
+    }
+ }
  
+  
 int main()
 {
     // MAIN CODE HERE
+    queue.call_every(100, read_potentiometer);
+    while(1){
+        wait_ms(100);
+        queue.dispatch(0);
+    }
 }
\ No newline at end of file