Myo – First day of happy hacking!

You can become a serverless blackbelt. Enrol to my 4-week online workshop Production-Ready Serverless and gain hands-on experience building something from scratch using serverless technologies. At the end of the workshop, you should have a broader view of the challenges you will face as your serverless architecture matures and expands. You should also have a firm grasp on when serverless is a good fit for your system as well as common pitfalls you need to avoid. Sign up now and get 15% discount with the code yanprs15!

It’s been a long wait but I have finally got my hands on a Myo armband this week!

2014-10-24 20.35.09


To start, you need to download and install Myo Connect from here. You need to go through the set up guide, which includes teaching the Myo armband how to classify the EMG readings from your arm to one of five recognized posture patterns:


It works well out of the box. Despite being a SDK unit, it’s able to interface with some applications such as PowerPoint and iTunes. Its scripting capability makes it easy to add support for other applications (more on this later).

The pattern detection can feel laggy – only by a fraction of a second but noticeable when you’re trying to play a game for instance. The accuracy of the pattern detection is not quite there yet either.

But both issues will improve over time as better firmware becomes available. The guys at Thalmic Labs will also fine tunes their math model with more data from real world usages.

So don’t let these temporary shortcoming hold you back from buying a Myo armband. (You might want to keep it out of the reach of your pets though, as mine tried to attack and take a bite out of it as soon as I took it off)


Programming your Myo

Once everything’s setup and running you will no doubt be itching to program against this wonderful piece of device.

The SDK allows you to write application to take full advantage of the Myo’s capabilities using C or C++.


Or, you can write Lua scripts to control applications using Myo. This allows you to map postures to keyboard or mouse signals (key up/down/press, mouse click, mouse movement, etc.). This approach has limitations – for instance, you can’t pass rotation information into a flight simulation program via keyboard and mouse signals alone. That said, there’s still plenty you can do with Lua scripts.


Lua Scripts

To run Lua scripts, you need to make sure Myo Connect is running (you’ll see it on your taskbar in Windows):


Right-clicking on the Myo Connect icon gives you the option to open the Myo Script Manager where you are able to load your Lua scripts.


This is how the Canvas blank.lua script you see above look in its full glory.

There are couple of things to note about this script:

  1. the scriptId variable specifies a unique ID for your script
  2. the onForegroundWindowChange function defines a callback function. Myo Connect will call this function when the active application changes. Our function specifies that the script should become active when you load the Canvas Blank mini game. It also allows the Myo to control mouse movement when that happens so that we can aim with our arm.
  3. the onPoseEdge function also defines a callback function. Myo Connect will call this function when a posture pattern turns on or off. Here we specify that a fist posture maps to a mouse left-click, and a fingersSpread posture maps to moving the mouse to the centre of the primary display.


It was straight forward to get the Myo armband working with Canvas Blank. But the playing experience is far from satisfactory due to the following reasons:

  • the lag and imprecise posture recognition
  • Myo’s mouse movement control is not smooth enough. Coupled with an occasional lag it breaks the sense of immersion (and makes me miss an awful lot!)
  • Posturing causes small movements in your arm. It is often enough to cause the mouse to move, another reason for my many misses…


Based on what I’ve seen so far, I’d say that Myo is not ready for applications that need good precision control yet. FPS games are probably out of the question for now.

Again, this is an area where I expect things to improve soon. Perhaps even by the time you see the final commercial unit (they’re shipping the first batches of SDK units right now).

What shouldn’t be underestimated, is how easy it was for me to integrate with the Myo via Lua scripts. In fact, it’s so easy that you don’t even have to be an experienced programmer to make it work.

To unlock the full potential of the Myo you need to fall back to the SDK. For now, it means developing your application in C/C++, but other language bindings should become available soon.


Useful Links

Liked this article? Support me on Patreon and get direct help from me via a private Slack channel or 1-2-1 mentoring.
Subscribe to my newsletter

Hi, I’m Yan. I’m an AWS Serverless Hero and the author of Production-Ready Serverless.

I specialise in rapidly transitioning teams to serverless and building production-ready services on AWS.

Are you struggling with serverless or need guidance on best practices? Do you want someone to review your architecture and help you avoid costly mistakes down the line? Whatever the case, I’m here to help.

Hire me.

Check out my new podcast Real-World Serverless where I talk with engineers who are building amazing things with serverless technologies and discuss the real-world use cases and challenges they face. If you’re interested in what people are actually doing with serverless and what it’s really like to be working with serverless day-to-day, then this is the podcast for you.

Check out my new course, Learn you some Lambda best practice for great good! In this course, you will learn best practices for working with AWS Lambda in terms of performance, cost, security, scalability, resilience and observability. We will also cover latest features from re:Invent 2019 such as Provisioned Concurrency and Lambda Destinations. Enrol now and start learning!

Check out my video course, Complete Guide to AWS Step Functions. In this course, we’ll cover everything you need to know to use AWS Step Functions service effectively. There is something for everyone from beginners to more advanced users looking for design patterns and best practices. Enrol now and start learning!

Are you working with Serverless and looking for expert training to level-up your skills? Or are you looking for a solid foundation to start from? Look no further, register for my Production-Ready Serverless workshop to learn how to build production-grade Serverless applications!

Find a workshop near you