Initial commit

Dependencies:   MODSERIAL mbed

Files at this revision

API Documentation at this revision

Comitter:
bjornnijhuis
Date:
Wed Sep 23 12:40:53 2015 +0000
Commit message:
Initial commit

Changed in this revision

MODSERIAL.lib 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
potmeter_read.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Wed Sep 23 12:40:53 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#8ef4f91813fd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 23 12:40:53 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/potmeter_read.cpp	Wed Sep 23 12:40:53 2015 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "MODSERIAL.h"
+
+Ticker output;
+
+AnalogIn pot(A0);
+DigitalOut led_r (LED_RED); 
+DigitalOut led_g (LED_GREEN);  
+DigitalOut led_b (LED_BLUE); 
+
+MODSERIAL pc(USBTX, USBRX);
+const int baudrate = 115200;            // Baudrate voor seriële verbinding
+const int output_rate = 1000;
+
+bool fn_go = false;
+
+void serial_output()
+{
+    fn_go = true;
+    led_r.write(false);
+    
+}
+
+int main()
+{
+    led_r.write(true);
+    led_g.write(false);    
+    led_b.write(true);     
+    output.attach_us(&serial_output,output_rate)    ;
+    pc.baud(baudrate);
+    while (true) {
+        led_b.write(false);  
+        
+        if(fn_go) {
+            led_g.write(true);            
+            float pot_val = pot.read();
+            pot_val = pot_val*4 - 2;
+            pc.printf("Potmeter value %.2f \n",pot_val);
+            
+            fn_go = false;
+        }
+    }
+}
\ No newline at end of file