Biorobotics_group_2 / Mbed 2 deprecated Read_potentiometer

Dependencies:   HIDScope mbed

Files at this revision

API Documentation at this revision

Comitter:
sjoerdbarts
Date:
Mon Sep 26 09:56:23 2016 +0000
Child:
1:3011d69df4a9
Commit message:
Initial program

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
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/MODSERIAL.lib	Mon Sep 26 09:56:23 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Sissors/code/MODSERIAL/#4737f8a5b018
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 26 09:56:23 2016 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#define SERIAL_BAUD 115200  // baud rate for serial communication
+// Homework set 1, excersize 9
+
+// Serial connection with PC
+Serial pc(USBTX,USBRX);
+
+AnalogIn pot(A0);
+DigitalOut led(D7);
+
+const float kTimeReadToggle = 0.5f;
+volatile float potvalue=0.0;
+
+void readanalog(){ 
+    printf("AnalogOut: %f \n\r", potvalue);
+    }
+
+int main()
+{
+    // Set baud connection with PC
+    pc.baud(SERIAL_BAUD);
+    pc.printf("\r\n ***THERMONUCLEAR WARFARE COMMENCES*** \r\n");
+    
+    Ticker tick_toggle_read;
+    tick_toggle_read.attach(readanalog,kTimeReadToggle);
+    
+    while(true){
+        potvalue = pot.read();
+        if(pot > 0.3f){
+        led=1;
+        } else {
+        led=0;
+        }    
+        }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 26 09:56:23 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file