Francisco Guerra
/
PRIM
Intermittent Stimuli
main.cpp
- Committer:
- franciscoguerra
- Date:
- 2016-01-14
- Revision:
- 6:1f29b4f65251
- Parent:
- 3:c9a411d4fe64
File content as of revision 6:1f29b4f65251:
#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); } } }