Script voor het weergeven van 1 EMG signaal met behulp van een OLIMEX shield. Let hierbij goed op dat je de juiste pinnetjes op het OLIMEX shield verbonden hebt, in dit geval A0 als uitgang. Verder maken we gebruik van 3,3 Volt!

Dependencies:   HIDScope mbed

Fork of EMG by Tom Tom

main.cpp

Committer:
tomlankhorst
Date:
2015-09-21
Revision:
14:f83354387756
Parent:
13:18d4cef1fdb4
Child:
15:0da764eea774

File content as of revision 14:f83354387756:

#include "mbed.h"
#include "MODSERIAL.h"
#include "HIDScope.h"

//Define objects
AnalogIn    emg(A0); //Analog input
Ticker      sample_timer;
HIDScope    scope(1);

/** Sample function
 * this function samples the emg and sends it to HIDScope
 **/
void sample()
{
    /* First, sample the EMG using the 'read' method of the 'AnalogIn' variable named 'emg' */
    double emg_value = emg.read();
    /* Second, set the sampled emg value in channel zero (the first channel) in the 'HIDScope' variable named 'scope' */
    scope.set(0,emg_value);
    /* Repeat the step above if required for more channels (channel 0 up to 5 = 6 channels)
    /* Finally, send all channels to the PC at once */
    scope.send();
}

int main()
{
    /**Attach the 'sample' function to the timer 'sample_timer'.
    * this ensures that 'sample' is executed every... 0.002 seconds
    */
    sample_timer.attach(&sample, 0.002);
    
    /*empty loop, sample() is executed periodically*/
    while(1){}
}