Control a Prosthetic Hand with Your Brain!

Let’s create some real next level assistive technology by controlling a prosthetic hand with our attention scores!

Estimated Time 

Approximately one hour for those with a complete NeuroMaker Hand. If the hand is not yet built or needs additional set up, this activity could take up to five hours in total!

Number of People

1- 2 students per materials set

Necessary Supplies

  • One NeuroMaker BCI Unit
  • One fully built NeuroMaker Hand
  • Computer

Necessary Program Files

Please see the code below

Pre Check Items

  • NeuroMaker BCI Unit is fully charged
  • NeuroMaker BCI Connect Software is running properly
  • NeuroMaker Hand is fully built. If the NeuroMaker Hand is not yet built, please view our build instructions here: https://neuromakerstem.com/user-portal/nmhand-portal/nmhand-student-projects/nmhand-build-hand/

Background

In this lesson, we are going to learn how to control five servos motors together in a prosthetic hand! Depending on our program and how much we focus or relax, we can create different gestures. This is the exact experiment that a group of Harvard students in the Harvard i-Lab completed to demo their first brain controlled device and now it’s your turn to test it out!

Table of Contents

Project Instructions

By this point, we have worked with all lights, servo motors and more using our attention data. Although we are controlling a prosthetic hand, the code below and project set up is no different than our previous servo project. The only difference is that we are using 5 servo motors for each finger instead of only one for the dial we created in the last lesson. Thankfully, the NeuroMaker Hand includes a shield on top of our controller so we don’t need to worry about dealing with lots of wires! A picture of the shield is shown on the right hand side of this text.

In our sample code below we are going to see what may be a few new concepts. We have one integer array that sets up the different servo objects and a four different custom functions we built to reset our finger states, create an open palm gesture, a fist gesture and a scissors gesture. If you need a quick refresher, please see the following links to learn more.

  • How to create a function with the Arduino software: https://startingelectronics.org/software/arduino/learn-to-program-course/15-functions/
  • How to use and understand an integer array: https://www.programmingelectronics.com/tutorial-13-how-to-use-arrays-with-arduino/

This project brings together many of the different concepts we have encountered so far. Once you have made the code below work for your purposes, think of a few other of these ideas that we can use to build on our understanding:

  • What other gestures can you code into the hand?
  • What other attention values can we use to control these gestures?
  • What useful applications could we create? Are there certain hand gestures we should present to represent different attention values? Can this hand grab or manipulate objects well using different attention score controlled gestures?

The Code

				
					

#include <Servo.h>
Servo servos[5];
int attentionData;


void setup() {

  Serial.begin(115200);

  servos[0].attach(6);
  servos[1].attach(5);
  servos[2].attach(4);
  servos[3].attach(3);
  servos[4].attach(2);

  resetFinger();
}

void loop() {

while (Serial.available() > 0){
    attentionData = Serial.read();
  }

  if (attentionData > 0 && attentionData < 30){
    
    gesture1();
  }

  else if (attentionData >= 30 && attentionData < 60){
    
    gesture2();
  }

  else if (attentionData >= 60 && attentionData <= 100){
    
    gesture3();
  }
}

void resetFinger(){

  servos[0].write(0);
  servos[1].write(180);
  servos[2].write(0);
  servos[3].write(0);
  servos[4].write(180);
  delay(1000);
}


void gesture1(){
  
  servos[0].write(180);
  servos[1].write(180);
  servos[2].write(0);
  servos[3].write(180);
  servos[4].write(0);
}

void gesture2(){
  
  servos[0].write(0);
  servos[1].write(180);
  servos[2].write(0);
  servos[3].write(0);
  servos[4].write(180);
}

void gesture3(){
  
  servos[0].write(180);
  servos[1].write(0);
  servos[2].write(180);
  servos[3].write(180);
  servos[4].write(0);
}