Devices & Components
Arduino Nano
Grove Shield for Arduino Nano
9V battery (generic)
MyoWare Muscle Sensor Development Kit
Jumper wires (generic)
SG90 Micro-servo motor
9V Battery Clip
Hardware & Tools
Solder Wire, Lead Free
Soldering iron (generic)
nylon thread roll
Hot glue gun (generic)
3D Printer (generic)
Project description
Code
control the claw by myoelectric sensor
c_cpp
1#include <Servo.h> 2 3//Threshold for servo motor control with muscle sensor. 4//You can set a threshold according to the maximum and minimum values of the muscle sensor. 5#define THRESHOLD 200 6 7//Pin number where the sensor is connected. (Analog 0) 8#define EMG_PIN 0 9 10//Define Servo motor 11 12const int servoPinA = 4; 13Servo servoA; 14 15const int servoPinB = 5; 16Servo servoB; 17 18const int servoPinC = 6; 19Servo servoC; 20 21const int servoPinD = 7; 22Servo servoD; 23 24/*-------------------------------- void setup ------------------------------------------------*/ 25 26void setup() { 27 28 //BAUDRATE set to 115200, remember it to set monitor serial properly. 29 //Used this Baud Rate and "NL&CR" option to visualize the values correctly. 30 Serial.begin(115200); 31 32 servoA.attach(servoPinA); 33 servoB.attach(servoPinB); 34 servoC.attach(servoPinC); 35 servoD.attach(servoPinD);// damos um "start" nos pulsos do servomotor, associando o pino de controle com a gerao de pulsos promovida pela funo e mtodo - "servo.attach()" 36 37 38 openGripper(); 39 //servoA.write(90); // Definimos o ngulo inicial do servo em 90 graus (posio central do servomotor) 40 //servoB.write(90); 41 //servoC.write(90); 42 //servoD.write(90); 43} 44 45/*-------------------------------- void loop ------------------------------------------------*/ 46 47void loop() { 48 49 //The "Value" variable reads the value from the analog pin to which the sensor is connected. 50 int value = analogRead(EMG_PIN); 51 52 //If the sensor value is GREATER than the THRESHOLD, the servo motor will turn to 170 degrees. 53 if (Serial.available()) 54 { 55 if (value > THRESHOLD) { 56 closeGripper(); 57 } else { 58 openGripper(); 59 } 60 } 61 62 //You can use serial monitor to set THRESHOLD properly, comparing the values shown when you open and close your hand. 63 Serial.println(value); 64} 65 66void openGripper() { 67 68 servoB.write(150); 69 servoC.write(0); 70 delay(500); 71 servoA.write(150); 72 servoD.write(0); 73 74} 75 76void closeGripper() { 77 78 servoB.write(0); 79 servoC.write(150); 80 delay(500); 81 servoA.write(0); 82 servoD.write(150); 83} 84
control the claw by myoelectric sensor
c_cpp
1#include <Servo.h> 2 3//Threshold for servo motor control with muscle 4 sensor. 5//You can set a threshold according to the maximum and minimum values 6 of the muscle sensor. 7#define THRESHOLD 200 8 9//Pin number where the sensor 10 is connected. (Analog 0) 11#define EMG_PIN 0 12 13//Define Servo motor 14 15const 16 int servoPinA = 4; 17Servo servoA; 18 19const int servoPinB = 5; 20Servo servoB; 21 22const 23 int servoPinC = 6; 24Servo servoC; 25 26const int servoPinD = 7; 27Servo servoD; 28 29/*-------------------------------- 30 void setup ------------------------------------------------*/ 31 32void setup() 33 { 34 35 //BAUDRATE set to 115200, remember it to set monitor serial properly. 36 37 //Used this Baud Rate and "NL&CR" option to visualize the values correctly. 38 39 Serial.begin(115200); 40 41 servoA.attach(servoPinA); 42 servoB.attach(servoPinB); 43 44 servoC.attach(servoPinC); 45 servoD.attach(servoPinD);// damos um "start" 46 nos pulsos do servomotor, associando o pino de controle com a gerao de pulsos promovida 47 pela funo e mtodo - "servo.attach()" 48 49 50 openGripper(); 51 //servoA.write(90); 52 // Definimos o ngulo inicial do servo em 90 graus (posio central do servomotor) 53 54 //servoB.write(90); 55 //servoC.write(90); 56 //servoD.write(90); 57} 58 59/*-------------------------------- 60 void loop ------------------------------------------------*/ 61 62void loop() 63 { 64 65 //The "Value" variable reads the value from the analog pin to which 66 the sensor is connected. 67 int value = analogRead(EMG_PIN); 68 69 //If the 70 sensor value is GREATER than the THRESHOLD, the servo motor will turn to 170 degrees. 71 72 if (Serial.available()) 73 { 74 if (value > THRESHOLD) { 75 closeGripper(); 76 77 } else { 78 openGripper(); 79 } 80 } 81 82 //You can use serial 83 monitor to set THRESHOLD properly, comparing the values shown when you open and 84 close your hand. 85 Serial.println(value); 86} 87 88void openGripper() { 89 90 91 servoB.write(150); 92 servoC.write(0); 93 delay(500); 94 servoA.write(150); 95 96 servoD.write(0); 97 98} 99 100void closeGripper() { 101 102 servoB.write(0); 103 104 servoC.write(150); 105 delay(500); 106 servoA.write(0); 107 servoD.write(150); 108} 109
Downloadable files
Battery connection pic2
Battery connection pic2

Myoeletric sensor schema.
Myoeletric sensor schema.

Order of muscle connectors
Place one electrode in the middle of the muscle body, connect this electrode to the RED snap connector. Place a second electrode at one end of the muscle body, connect this electrode to the GREEN snap connector. Place a third electrode on a bony or non-muscular part of your body near the targeted muscle, connect this electrode to the YELLOW snap connector.
Order of muscle connectors

Battery connection pic1
Battery connection pic1

Example of functionality
Example of functionality

Example of functionality
Example of functionality

Myoeletric sensor schema.
Myoeletric sensor schema.

Myoelectric sensor connection
Myoelectric sensor connection

Battery connection pic1
Battery connection pic1

Order of muscle connectors
Place one electrode in the middle of the muscle body, connect this electrode to the RED snap connector. Place a second electrode at one end of the muscle body, connect this electrode to the GREEN snap connector. Place a third electrode on a bony or non-muscular part of your body near the targeted muscle, connect this electrode to the YELLOW snap connector.
Order of muscle connectors

Battery connection pic2
Battery connection pic2

Documentation
Claw Parts CAD
Modeling of the claw parts in Solid Works.
Claw Parts CAD
Claw Parts CAD
Modeling of the claw parts in Solid Works.
Claw Parts CAD
Comments
Only logged in users can leave comments