checkje
Dependencies: HIDScope MODSERIAL mbed
Fork of EMG by
main.cpp
- Committer:
- daniQQue
- Date:
- 2016-10-28
- Revision:
- 23:7de28be57d75
- Parent:
- 22:10f62c4f88eb
File content as of revision 23:7de28be57d75:
#include "mbed.h" #include "HIDScope.h" #include "MODSERIAL.h" //Define objects AnalogIn emg0( A0 ); AnalogIn emg1( A1 ); Ticker sample_timer; HIDScope scope( 2 ); DigitalOut led(LED1); MODSERIAL pc(USBTX,USBRX); /** Sample function * this function samples the emg and sends it to HIDScope **/ void sample() { /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */ scope.set(0, emg0.read() ); scope.set(1, emg1.read() ); /* Repeat the step above if required for more channels of required (channel 0 up to 5 = 6 channels) * Ensure that enough channels are available (HIDScope scope( 2 )) * Finally, send all channels to the PC at once */ scope.send(); /* To indicate that the function is working, the LED is toggled */ led = !led; pc.printf("send\r\n"); } int main() { /**Attach the 'sample' function to the timer 'sample_timer'. * this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz */ pc.baud(115200); sample_timer.attach(&sample, 0.001); /*empty loop, sample() is executed periodically*/ while(1) {} }