Skip to content

Commit f7f42f8

Browse files
committed
Adding example sketch for the newly merged filtering feature.
1 parent 5bb31f6 commit f7f42f8

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <Libdevlpr.h>
2+
3+
// create a DEVLPR object with the pin we have connected on the shield
4+
// can create multiple for different pins if stacking shields
5+
// create this one configured for a 60Hz notch filter (50Hz also available)
6+
Devlpr devlpr(A0, FILTER_60HZ);
7+
8+
void printEMG(Devlpr *d) {
9+
// grab the most recent EMG values, filtered and raw
10+
int filtered = d->lastValueCentered(true);
11+
int raw = d->lastValueCentered(false);
12+
// we will print four values each time: -1024, 1024, filtered, and raw EMG
13+
// the -1024 and 1024 simply give us a top and bottom line in the plotter
14+
Serial.print("-1024 1024 ");
15+
Serial.println(filtered);
16+
Serial.print(" ");
17+
Serial.println(raw);
18+
}
19+
20+
void setup() {
21+
// prepare Serial for printing to the plotter
22+
Serial.begin(2000000);
23+
// add a printing function as a scheduled callback for our Devlpr
24+
// here we set the function to be called every 1ms
25+
devlpr.scheduleFunction(printEMG, 1);
26+
}
27+
28+
void loop() {
29+
// let the DEVLPR library do its job
30+
devlpr.tick();
31+
}

0 commit comments

Comments
 (0)