Intermittent Stimuli

Dependencies:   mbed tsi_sensor

Revision:
6:1f29b4f65251
Parent:
3:c9a411d4fe64
--- a/main.cpp	Tue Feb 19 23:49:45 2013 +0000
+++ b/main.cpp	Thu Jan 14 16:02:26 2016 +0000
@@ -1,19 +1,66 @@
-#include "mbed.h"
-
-Ticker tick;
-DigitalOut led1(LED_RED);
-DigitalOut led2(LED_GREEN);
-
-void flip() {
-    led2 = !led2;
-}
-
-int main() {
-    tick.attach(&flip, 0.7); // setup ticker to call flip led2 after 0.7 seconds
-
-    // spin in a main loop.
-    while (true) {
-        led1 = !led1;
-        wait (0.3); // flip led1 every 0.3 seconds
-    }
-}
\ No newline at end of file
+#include "mbed.h"
+//#include "FastPWM.h"
+#include "tsi_sensor.h"
+
+#define V1_CLOSE  D2
+#define V1_OPEN   D3
+#define V2_CLOSE  D4
+#define V2_OPEN   D5
+#define V3_CLOSE  A2
+#define V3_OPEN   A3
+#define V4_CLOSE  D8
+#define V4_OPEN   D9
+#define EXTERNAL1_td PTC2
+#define EXTERNAL2_td PTB1
+
+//#define TSI_A PTB16
+//#define TSI_B PTB17
+
+Ticker flipper;
+//PwmOut v1open(V1_OPEN);
+//PwmOut v1close(V1_CLOSE);
+//TSIAnalogSlider slider(TSI_A, TSI_B, 100);
+
+DigitalOut v2open(V2_OPEN);
+DigitalOut v2close(V2_CLOSE);
+DigitalOut v1open(V1_OPEN);
+DigitalOut v1close(V1_CLOSE);
+
+AnalogIn ain1_td(EXTERNAL1_td);
+AnalogIn ain2_td(EXTERNAL2_td);
+
+//void flip() {
+   // v1open = !v1open;
+//}
+
+int main() {
+    
+    //flipper.attach(&flip, 2); // the address of the function to be attached (flip) and the interval (2 seconds)
+    // spin in a main loop. flipper will interrupt it to call flip
+    
+    while (true){
+    v1open = 0;
+    v1close =1;
+    v2open = 0;
+    v2close =1;
+            //Front balloon settings
+            while (ain1_td.read()>0.001) {
+                v1open = !v1open; //Inflation;
+                v1close = !v1close; 
+                wait(0.025); //Inflation time;
+                v1close = !v1close;//Deflation;
+                v1open = !v1open;
+                wait(ain1_td.read()); //Defines frequency(reads the frequency settings for front balloon defined in LabVIEW);
+            } 
+            //Back balloon settings
+            while (ain2_td.read()>0.001) {
+                v2open = !v2open;//Inflation;
+                v2close = !v2close;
+                wait(0.025); //Inflation time;
+                v2close = !v2close;//Deflation;
+                v2open = !v2open;
+                wait(ain2_td.read());//Defines frequency(reads the frequency settings for back balloon defined in LabVIEW);
+            } 
+    }
+}
+ 
\ No newline at end of file