
checkje
Dependencies: HIDScope MODSERIAL mbed
Fork of EMG by
main.cpp
00001 #include "mbed.h" 00002 #include "HIDScope.h" 00003 #include "MODSERIAL.h" 00004 //Define objects 00005 AnalogIn emg0( A0 ); 00006 AnalogIn emg1( A1 ); 00007 00008 Ticker sample_timer; 00009 HIDScope scope( 2 ); 00010 DigitalOut led(LED1); 00011 MODSERIAL pc(USBTX,USBRX); 00012 00013 /** Sample function 00014 * this function samples the emg and sends it to HIDScope 00015 **/ 00016 void sample() 00017 { 00018 /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */ 00019 scope.set(0, emg0.read() ); 00020 scope.set(1, emg1.read() ); 00021 /* Repeat the step above if required for more channels of required (channel 0 up to 5 = 6 channels) 00022 * Ensure that enough channels are available (HIDScope scope( 2 )) 00023 * Finally, send all channels to the PC at once */ 00024 scope.send(); 00025 /* To indicate that the function is working, the LED is toggled */ 00026 led = !led; 00027 pc.printf("send\r\n"); 00028 } 00029 00030 int main() 00031 { 00032 /**Attach the 'sample' function to the timer 'sample_timer'. 00033 * this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz 00034 */ 00035 00036 pc.baud(115200); 00037 sample_timer.attach(&sample, 0.001); 00038 00039 /*empty loop, sample() is executed periodically*/ 00040 while(1) {} 00041 }
Generated on Mon Jan 28 2019 22:52:18 by
