I have been working on an EMG widget in order to improve interfacing with the Open Bionics project I worked on previously. In this project I worked toward two goals: to create easy and concise digital switch tripping and to create an easy analog output. The video below showcases what I've gotten done so far:
The code for this project will very shorty be on github in the form of the newest iteration of the OpenBCI GUI. Here's a link for when that goes live (check out my pull requests if you're impatient). If you notice in the video the little graph I have on screen, that is my cheat-sheet for all the different digital commands. The analog code works by mapping the EMG data from a jaw clench to a value between 0 and 100, then writes that value to the Open Bionics hand. The digital code works by waiting for a user to trip a switch, then untrip said switch. It then waits a certain amount of time for more input, and if there is no more input it triggers the event.
The code itself is pretty self-explanatory (also well documented), and it works well with any serial output that you'd like. If you'd like to work with digital switches you'll need to add some logic to the process() function within EMG_Widget.pde, but analog data should all be configurable from the events themselves. My next goal with this is to create a dynamic threshold that moves based on rolling averages. But I think that's it for this post! Happy hacking!